v0.38.10
This commit is contained in:
1 parent
38a23e2210
commit
45b1fc04c7
36 files changed
+9594
-7892
No files matched your search
+46
-10
@@ -37,14 +37,45 @@ Set **Default grace (seconds)** in Settings → Cache (default **60**, range 0..
|
||||
| Client `only-if-cached` | **Fresh/stale eligible HIT**, or **504** if no reusable representation; never fetch origin on MISS | Same |
|
||||
| Client `min-fresh`, `max-stale`, positive `max-age` | Keep constraints; an otherwise fresh object can be rejected by `min-fresh`, while eligible stale entries can be served by `max-stale` | Same |
|
||||
| Origin `no-cache` with `ETag`/`Last-Modified`, fallback TTL = `0` | Store for **conditional revalidation** (`304`) but never fresh-HIT without checking origin | Same |
|
||||
| Origin **`public, no-cache`** and explicit fallback TTL `> 0` | Treat the administrator's configured **Fallback TTL for public responses** as shared freshness (capped by max TTL), even when the origin has no validator; this explicitly overrides origin `no-cache` | Validator-only revalidation, no override |
|
||||
| Origin `no-cache` (with or without `public`) and explicit fallback TTL `> 0` | Treat the administrator's configured fallback TTL as shared freshness (capped by max TTL), even when the origin has no validator; this explicitly overrides origin `no-cache` | Validator-only revalidation, no override |
|
||||
| Origin `max-age=0` / already expired, with `stale-if-error`, a validator or client `max-stale` | Retain the expired representation; it does not become a fresh HIT. Can serve stale on an eligible error, revalidate, or honor explicit client allowance | Same |
|
||||
| Origin `Surrogate-Control: no-store` | Do not store, even when a fallback TTL is configured; this is an additional compatibility-mode safeguard | Legacy response policy |
|
||||
| Origin `private`, `no-store`, `Set-Cookie`, invalid `Vary` | Must not enter shared cache; configured static-cookie exceptions do not override response privacy | Same |
|
||||
| Eligible cached object after TTL | Implicit background-refresh grace up to **60 seconds by default** (configurable with `cache.varnish_grace_seconds`, `0` disables it) **only** for entries initially fresh with **no** origin `stale-while-revalidate` directive; explicit `stale-while-revalidate=0` disables implicit grace. Existing `must-revalidate` / `proxy-revalidate` restrictions still apply | No implicit grace |
|
||||
| Cookies, Authorization, `Vary`, per-vhost exclusions/force, query/range restrictions, BAN/PURGE, request collapse, transforms, compression, HOT/COLD | Existing RustProxy mechanisms remain in effect | Same |
|
||||
| Cookie requests | Bypass by default; an explicit cache `lookup` action (imported from VCL `return(hash)`) can allow a GET/HEAD with Cookie to reach cache. A matching `pass` rule wins, and retained Cookie values always partition the cache variant. | Cookie requests bypass without this VCL exception |
|
||||
| Authorization, `Vary`, per-vhost exclusions/force, query/range restrictions, BAN/PURGE, request collapse, transforms, compression, HOT/COLD | Existing RustProxy mechanisms remain in effect | Same |
|
||||
|
||||
**Important:** using a positive fallback TTL to reuse an origin response marked `public, no-cache` is an **explicit administrative freshness override**. It can serve outdated content for that duration; leave fallback TTL at `0` if the backend's `no-cache` must always be honored. The fallback override applies only to responses carrying `public`, not to private/no-store/Set-Cookie responses or `Surrogate-Control: no-store`. The configured `max_ttl_seconds` still caps remaining freshness. Without fallback TTL, origin `no-cache` still requires an origin validator to be stored. An origin `max-age=0` is never made fresh merely because `stale-if-error` is present.
|
||||
**Important:** in compatibility mode, a positive fallback TTL overrides an origin response's `no-cache` **even without `public`**. This is an explicit administrative freshness override, not Varnish's built-in handling of `no-cache` (which normally does not cache it), nor strict RFC 9111 behavior. It can serve outdated content for that duration; leave fallback TTL at `0` if the backend's `no-cache` must always be honored. Privacy barriers (`private`, `no-store`, `Set-Cookie`, `Surrogate-Control: no-store`) still apply. The configured `max_ttl_seconds` caps freshness. With fallback TTL 0, origin `no-cache` needs an origin validator to be stored for revalidation. An origin `max-age=0` is never made fresh merely because `stale-if-error` is present.
|
||||
|
||||
### VCL ordering and supported backend header overrides
|
||||
|
||||
Imported VCL is compiled into the **same rule engine** as the global and per-Vhost graphical rules. The editor discards in-flight import results if its source is changed or the importer is closed, so cancelled conversions cannot silently add obsolete rules. The import endpoint returns `warnings` for unsupported Varnish operations; do not deploy an imported rule set until those warnings are reviewed. RustProxy is not an arbitrary VCL interpreter, and `pipe`, `restart`, `purge`, `synth`, dynamic VCL expressions and custom subroutines are not equivalent to Varnish.
|
||||
|
||||
- `vcl_recv` runs before `vcl_hash` (the latter runs after `return(hash)`). `return(pass)` stops normal request rules. Terminal `return(deliver)` stops the relevant response/deliver stage. Supported request rewrites also reach the origin on cache-disabled routes; such routes still cannot store or serve from cache.
|
||||
- `if`/`elsif`/`else`, nested guards, supported `&&`/`||`/`!` expressions and request-cookie/query edits preserve order. Later matching conditions see supported earlier mutations.
|
||||
- `vcl_backend_response` supports `set/unset beresp.http.Header` for **constant valid headers**, as well as TTL, grace and uncacheable controls. Backend header changes affect both admission policy and the response delivered to the client (also on BYPASS). Hop-by-hop, `Set-Cookie`, length, Host and other protected fields cannot be assigned by general header actions; use the dedicated Set-Cookie removal action.
|
||||
- `vcl_deliver` supports constant `set/unset resp.http.Header` and `return(deliver)`; graphical `default_header` provides set-if-missing. Ordered operations are reflected in evaluation and delivery.
|
||||
- Per-Vhost rules are evaluated before applicable global rules. A vhost edit to a request cookie/query rewrite, response/deliver header, or request routing aspect wins over a conflicting global edit. In the same scope, later writes supersede earlier ones unless a matching rule has `stop=true` or terminal `return`.
|
||||
- Credential separation remains mandatory for shared caching. `return(hash)` on a request carrying `Cookie` partitions RustProxy's cache variant by the **complete remaining Cookie**, and includes `Vary: Cookie` for downstream caches. Session cookies must be intercepted by an earlier `return(pass)` rule. Authorization never becomes shareable through this exception.
|
||||
|
||||
### Complete VCL support and `Vary`/header overrides
|
||||
|
||||
See [VCL compatibility and header overrides](VCL.md) for a statement-by-statement compatibility matrix, global/per-Vhost priority, stage timing, exact `set`/`unset` support, `Vary` behavior and protected headers. **`beresp.http.Vary` affects cache variants; `resp.http.Vary` only affects the outgoing header.** Unsetting either can break downstream cache correctness. `set/unset beresp.http.Cache-Control` changes cache admission policy, while deliver-stage header edits do not. A deliberately rewritten `private`/`no-store` header or removed `Set-Cookie` no longer protects the representation, so use these actions only for public content.
|
||||
|
||||
### Explicit Cookie lookup with imported VCL
|
||||
|
||||
Varnish defaults to `pass` on `Cookie`, but custom `return(hash)` can opt in. RustProxy's VCL importer supports this explicit opt-in in `varnish_compatible` mode only. Use an early `pass` rule for session cookies, followed by `return(hash)` for eligible requests:
|
||||
|
||||
```vcl
|
||||
sub vcl_recv {
|
||||
if (req.http.Cookie ~ "(^|; *)[sS][eE][sS][sS][iI][oO][nN][iI][dD]=") {
|
||||
return (pass);
|
||||
}
|
||||
return (hash);
|
||||
}
|
||||
```
|
||||
|
||||
The VCL importer supports a subset of VCL, not full Varnish runtime semantics. Imported `return(hash)` becomes a `lookup` request action. When Cookie remains on a request, RustProxy matches cache entries on that Cookie (not only the default URL key), avoiding accidental cross-user reuse; remove irrelevant tracking cookies first to improve HIT rate. `Authorization`, non-GET/HEAD methods, request `no-store`, access checks, private/no-store response headers and backend `Set-Cookie` are not overridden by this action. With compatibility disabled, the `lookup` action does not override Cookie BYPASS.
|
||||
|
||||
This is **a Varnish-inspired policy subset, not full Varnish binary/VCL compatibility**. RustProxy deliberately keeps an explicit zero-by-default fallback TTL instead of Varnish's implicit 120-second default, retains client controls beyond hard reload, enforces multi-tenant and cookie/Authorization safety rules, and does not implement hit-for-miss/hit-for-pass markers. The current compatibility-specific `Surrogate-Control` safeguard handles `no-store`; it does **not** interpret every Surrogate-Control extension or use Surrogate-Control `max-age` as a TTL override. Different VCL configurations can behave differently.
|
||||
|
||||
@@ -69,18 +100,19 @@ In **Vhosts → Cache**, overrides for static extensions, bypass path prefixes a
|
||||
|
||||
| Stage | VCL equivalent | Conditions | Actions |
|
||||
|---|---|---|---|
|
||||
| Request | `vcl_recv`, `vcl_hash` | host, URL, path, extension, method, query parameter, request header, cookie, client IP | bypass cache (`pass`), remove cookies (all or all except listed), remove query parameters (list with `*`, or keep only listed), add a header or cookie value to the cache key |
|
||||
| Backend response | `vcl_backend_response` | the request conditions plus status (`200`, `4xx`, `500-599`), Content-Type, response header | set TTL, set grace, do not store, ignore backend `Cache-Control`/`Expires`, remove `Set-Cookie` |
|
||||
| Request | `vcl_recv`, `vcl_hash` | host, URL, path, extension, method, query parameter, request header, cookie, client IP | bypass cache (`pass`), explicit lookup (`hash`), remove cookies (all or all except listed), remove query parameters (list with `*`, or keep only listed), set/remove **safe request headers**, add a header or cookie value to the cache key |
|
||||
| Backend response | `vcl_backend_response` | the request conditions plus status (`200`, `4xx`, `500-599`), Content-Type, response header | set TTL, set grace, do not store or **undo a rule-imposed do-not-store**, ignore backend `Cache-Control`/`Expires`, remove `Set-Cookie`, set/remove permitted backend response headers |
|
||||
| Deliver | `vcl_deliver` | the request and response conditions | set a response header, set it only if the response lacks it, or remove it |
|
||||
|
||||
- Rules run top to bottom (drag to reorder). Each rule matches when all (or any) of its conditions match; a rule without conditions matches every request. *Stop evaluating later rules* ends the stage, like `return` in VCL.
|
||||
- Vhost rules run before global rules. A global rule can be limited to selected vhosts. For TTL, grace, bypass and *do not store*, the first matching rule wins: the vhost editor and the global list show which rules override others, and the tester lists every overridden action. *Ignore global cache rules* switches global rules off for that vhost.
|
||||
- Request rules change the request like VCL does: removed cookies and query parameters are also not sent to the backend. Values added to the cache key create separate variants (for example one per `lang` cookie).
|
||||
- Vhost rules run before applicable global rules. A matching vhost assignment to request routing/cookie stripping/query stripping, TTL or grace overrides the same aspect in a global rule. Within the same scope later matching assignments win unless a terminal rule stops evaluation. Response and delivered header edits have per-header ownership; `stop` and imported VCL `return(...)` stop the current stage. The tester shows suppressed scalar overrides. *Ignore global cache rules* switches global rules off for that vhost.
|
||||
- Request rules change the request like VCL does: removed cookies, query parameters and safe selected request headers also affect the backend. Request-header edits are visible to subsequent rules and hashing; authorization, identity, transport and request cache policy fields are protected. Values added to the cache key create separate variants (for example one per `lang` cookie).
|
||||
- Safeguards stay in place: only GET/HEAD without a body are cached, `Authorization`, Basic Auth, login providers and sticky sessions still bypass the cache, and a response with `Set-Cookie` is never stored unless a rule removes it. *Ignore backend Cache-Control* keeps the original header for the browser; it only changes what RustProxy stores.
|
||||
- **Test a request** checks the rules on screen (including unsaved edits) against a sample URL, headers, client IP and backend response, and shows the decision, cache key, TTL/grace, matched and overridden rules. **Import VCL** converts supported statements from `vcl_recv`, `vcl_hash`, `vcl_backend_response`/`vcl_fetch` and `vcl_deliver` (`if`/`elsif`/`else`, `~`, `!~`, `==`, `!=`, status comparisons, `return (pass)`, `unset req.http.Cookie`, query-parameter `regsuball` on `req.url`, `hash_data(req.http.X)`, `beresp.ttl`, `beresp.grace`, `beresp.uncacheable`, `unset beresp.http.Set-Cookie`, `set/unset resp.http.X`); everything else is listed as a warning. **Copy as VCL** shows the equivalent VCL (read-only).
|
||||
- For the exact import syntax, warnings, `Vary` mutation semantics and header restrictions see [VCL compatibility](VCL.md).
|
||||
- **Test a request** is a compact, responsive two-section tester (HTTP request / example backend response) shared by **Settings → Cache → Rules**, **Vhosts → Cache** and **Docker vhosts → Cache**. It checks rules on screen (including unsaved edits) against a sample URL, headers, client IP and backend response, and shows the decision, cache key, TTL/grace, matched and overridden rules. In global settings it tests unsaved **global** rules plus the selected vhost's *saved* rules/settings. In a vhost or Docker service editor it tests unsaved **local** rules plus the *saved* applicable global rules unless **Ignore global cache rules** is checked. This is a simulated decision, not a real HTTP request or a prediction of HIT after two requests. Other unsaved cache settings, such as the vhost TTL or the global compatibility toggle, are not submitted by the tester. For a path-only local test (e.g. `/product`), the panel supplies the current editor hostname as `Host` if the headers field does not already contain `Host`; a full URL or an explicit `Host` takes precedence. Unsaved/unpublished Docker vhosts may not yet have a saved vhost ID; the test then cannot model every saved per-vhost setting. Check the resulting host/key and rules before trusting the preview. **Import VCL** converts supported statements from `vcl_recv`, `vcl_hash`, `vcl_backend_response`/`vcl_fetch` and `vcl_deliver` (`if`/`elsif`/`else`, `~`, `!~`, `==`, `!=`, status comparisons, `return (pass)`, `unset req.http.Cookie`, safe constant `set/unset req.http.X`, restricted query-parameter `regsuball` on `req.url`, `hash_data(req.http.X)`, `beresp.ttl`, `beresp.grace`, `beresp.uncacheable = true/false`, `unset beresp.http.Set-Cookie`, `set/unset beresp.http.X` (constant values; non-protected headers), `set/unset resp.http.X`, terminal `return(hash)`/`return(lookup)`/`return(pass)`/`return(deliver)`, nested boolean guards); unsupported operations (including arbitrary URL rewrites) produce import warnings rather than guessed actions. **Copy as VCL** is a read-only **approximate preview**, not an exact round-trip or configuration backup. Imports with warnings now require explicit **Add partial import (reviewed)** before converted rules are added to the unsaved editor.
|
||||
- Limits: 128 rules per list, 16 conditions and 16 actions per rule, regular expressions with linear-time matching. Match counters live in memory (reset on restart) and are exported as `rust_proxy_cache_rule_matches_total{origin,vhost,rule}` when the *Domains and effectiveness* metric group is enabled.
|
||||
- Rules apply to Reverse Proxy vhosts (including Docker vhosts) while the cache is active for the route; built-in web server sources are not affected.
|
||||
- **Deliver rules apply to the whole application.** Since 0.37.2 they run for every response of the vhost — also when caching is switched off for it, for bypassed requests and for misses — so they can override headers such as `Cache-Control` for browsers, or add security headers, for an entire application. *Set header if missing* (`default_header`) keeps a header the backend already sent. Templates: *Browser cache for static files (30 days)*, *No browser cache for HTML and /admin*, *Default security headers*. Request and backend-response rules still run only while the cache is active for the route.
|
||||
- **Deliver rules apply to the whole application.** Since 0.37.2 they run for every response of the vhost — also when caching is switched off for it, for bypassed requests and for misses — so they can override headers such as `Cache-Control` for browsers, or add security headers, for an entire application. *Set header if missing* (`default_header`) keeps a header the backend already sent. Templates: *Browser cache for static files (30 days)*, *No browser cache for HTML and /admin*, *Default security headers*. Supported request rewrites and backend-response header edits can also affect normal reverse-proxy traffic on a cache-disabled route, but they do **not** enable cache storage. See [VCL stages](VCL.md#where-to-import-rule-order-and-activation) for the exact scope.
|
||||
- Docker vhosts have their own rules too: in **Docker vhosts**, enable *Cache* for the service and open **Cache for this vhost** (default TTL and rules). The global rule vhost picker and the tester list Docker vhosts (marked *Docker*) next to ordinary vhosts; `GET /api/cache/rules/targets` returns the same list.
|
||||
|
||||
## Stored object rules
|
||||
@@ -88,7 +120,7 @@ In **Vhosts → Cache**, overrides for static extensions, bypass path prefixes a
|
||||
- Reuse is scoped by frontend scheme, Host, exact client URL, Vhost/content policy and eligible `Vary` dimensions. HTTP and HTTPS objects do not cross-share.
|
||||
- GET and suitable HEAD requests may reuse a full object; changing request methods do not silently invalidate all cached GET results.
|
||||
- Authorization, dynamic cookies, `Set-Cookie`, sticky-affinity cookies, Tinyauth and other private signals normally cause **BYPASS**. The static-extension exception may ignore `Vary: Cookie` only if the explicitly public response is otherwise safe to store and the global/vhost option is on. It never overrides `private`, `no-store` or `Set-Cookie`; the origin must guarantee that the complete asset response is not session-dependent.
|
||||
- Origin status, response size, TTL, unsupported metadata, range/conditional semantics and request/client cache directives can prevent fill or require validation.
|
||||
- Only status **200 OK** responses can be stored in HOT/COLD. A cache-rule `ttl` targeting `404`, `301` or `302` cannot override this storage restriction; the older 404 TTL rule template was removed because it never produced HIT. Other response sizes, TTL, unsupported metadata, range/conditional semantics and request/client cache directives can prevent fill or require validation.
|
||||
- A Web Service selected as a Vhost source uses the same cache policy for eligible local files. File changes can be checked with `ETag` / `Last-Modified`; a 304 validation may refresh a stored body without downloading it again.
|
||||
|
||||
## Freshness and diagnostics
|
||||
@@ -114,6 +146,10 @@ done
|
||||
|
||||
Look for cache reason labels including `request_cookie`, `request_authorization`, `response_cache_control`, `route_disabled` and `cache_hit` when diagnostic headers are enabled. A `MISS` alone does not prove the object was admitted to HOT/COLD.
|
||||
|
||||
### In-panel cache and VCL guide
|
||||
|
||||
Click **Cache & VCL guide** in **Settings → Cache**, **Vhosts → Cache** or a Docker service's **Cache** editor for the same interactive modal. The example-insertion target is the **editor that opened the modal** (global, ordinary vhost or Docker vhost), not always the global rules. The context badge identifies the destination, and the scope note explains which rules/settings are inherited and which are local. Opening the guide from a vhost does not save or modify global rules. It shows the **current form values** for compatibility mode, fallback TTL and grace, including a warning if the cache is disabled. The form may have unsaved changes; the modal does not apply settings. Example VCL snippets explain how `Cookie`, `Vary`, safe `req.http.*`, `beresp.http.*`, `resp.http.*`, `beresp.uncacheable = false` and `return(hash)` affect cache decisions. The **Insert into VCL importer** buttons copy a starting snippet into that editor's Rules import textarea (without importing or saving the rule) and invalidate older import previews; warnings now require explicit approval of a partial import. The guide warns that only 200 responses can be stored, and that VCL export is an approximate view. Validate the rule tester before saving. The modal explicitly lists unsupported VCL hooks and includes a short HIT/MISS/BYPASS checklist. For complete syntax, use [VCL import](VCL.md).
|
||||
|
||||
## Cache response headers and upstream diagnostics
|
||||
**RFC 9211:** `Cache-Status` is a structured list of cache hops, ordered from the origin-side cache toward the client. RustProxy **does not replace or suppress** an upstream `Cache-Status`. When **Settings → Cache → Expose Cache-Status** is enabled and RustProxy makes a cache decision, it appends its own `RustProxy` member to the existing list; multiple HTTP header fields are an equivalent wire representation of the same list. There is no `backend=hit/miss` parameter: the upstream's own members already describe its cache decisions.
|
||||
|
||||
|
||||
Reference in new issue
Block a user