v0.39.2
This commit is contained in:
1 parent
d455028de3
commit
5b2eaaff61
36 files changed
+2544
-102
No files matched your search
+68
-3
@@ -119,13 +119,78 @@ With the policy enabled, the middle request stays `HIT` if the entry is fresh. C
|
||||
|
||||
In **Vhosts → Cache**, overrides for static extensions, bypass path prefixes and unsafe force targets each place the enable/override checkbox immediately above the associated multiline list. The fields are disabled while their individual override is off; their saved values and cache policy are unchanged. Never enable unsafe forced caching for personalized responses.
|
||||
|
||||
## Cache decision precedence, explicit `pass` and public static assets
|
||||
|
||||
**Applies to RustProxy 0.39.2.** Every reason that keeps a request away from the HOT/COLD cache is classified by one central decision (`src/cache/policy/decision.rs`), used by live traffic and by **Test a request**. Reasons are evaluated strongest first:
|
||||
|
||||
| # | Source | Examples (`X-Cache-Reason`) | Can a static-file option override it? |
|
||||
|---|---|---|---|
|
||||
| 1 | **Security** | `admin_control_plane`, `basic_auth`, auth provider id (`tinyauth`, `oidc`, …), `sticky_cookie`, `request_authorization` | Never |
|
||||
| 2 | **Configuration** | `cache_disabled`, `route_disabled`, `request_upgrade` | Never |
|
||||
| 3 | **Explicit VCL `pass`** (`return(pass)`, action `pass`) | `cache_rule` | Never |
|
||||
| 4 | **VCL Cookie guard** (`return(cookie_pass)`, action `cookie_pass`) | `cache_rule_cookie` | Yes, for public static assets only (below) |
|
||||
| 5 | **Default request policy** | `request_cookie`, `request_method`, `request_body`, `path_excluded`, `query_excluded`, `request_no_store`, … | `request_cookie` only, for configured static extensions (existing behavior) |
|
||||
| 6 | **Backend response** | `response_status`, `response_set_cookie`, `response_cache_control`, `response_vary`, `response_vary_cookie`, `response_static_not_public`, `response_static_dynamic`, … | Never |
|
||||
|
||||
### `pass` versus `cookie_pass`
|
||||
|
||||
- **`pass`** is an explicit, absolute bypass. RustProxy never relaxes it, whatever the resource type or the global options. Existing rules and imported `return(pass)` keep exactly this meaning; there is no automatic conversion.
|
||||
- **`cookie_pass`** is a *Cookie/session guard*: "bypass because this request carries (session) cookies". For pages, HTML, APIs and every other non-static request it behaves exactly like `pass`. A `cookie_pass` rule must have at least one non-negated Cookie condition (the `cookie` field or the `Cookie` request header); other bypass reasons belong in a separate `pass` rule. In VCL it is written `return(cookie_pass);` — a **RustProxy extension** (stock Varnish only knows `return(pass)`).
|
||||
- The session templates (**Any Cookie**, **Common session cookies**, WordPress/WooCommerce cookies, Django, Laravel/PHP, Auth.js, ASP.NET, Drupal) and **CDN: bypass remaining cookies** now insert `cookie_pass`. Path, method, Authorization, preview, checkout, webhook and other guards still insert `pass`. WordPress and WooCommerce now insert two rules (explicit path `pass` + Cookie guard) instead of one mixed *any* rule.
|
||||
|
||||
### Public static assets with a session cookie
|
||||
|
||||
Before this change a logged-in browser got `BYPASS / cache_rule` for every CSS, JS, image and font, because the session rule ran first and the static-file options never got a chance to apply. Now, with **Settings → Cache → Ignore request cookies for static files** on (default), a `cookie_pass` bypass is relaxed **only if all** of the following hold:
|
||||
|
||||
1. the winning request decision is a `cookie_pass` guard, not `pass`;
|
||||
2. GET or HEAD, no `Authorization`, and a `Cookie` header is present;
|
||||
3. the URL path ends in one of the configured static extensions (case-insensitive; the query string is ignored for this test and remains part of the cache key);
|
||||
4. evaluating the rules **without any Cookie guard** gives no `pass` — so an explicit `pass` placed after a terminal Cookie guard (for example a `preview` cookie or `/admin` path rule) still wins;
|
||||
5. evaluating the rules **without the Cookie header** gives no `pass` — the same URL is also cacheable for an anonymous client.
|
||||
|
||||
The relaxed request then follows the normal static-cookie policy: Cookie is excluded from the cache key, so logged-in and anonymous clients share one object; header, cookie and query edits of the *non-guard* rules (for example tracking-parameter stripping) apply as for any other client, and `hash_cookie` / `hash_header` variants keep partitioning the key. The first relaxed MISS is reported as `cache_miss_static_cookie`. Nothing has to be added to each session rule.
|
||||
|
||||
The extension is only a **candidate** signal. The browser's Cookie is still forwarded to the backend on a MISS, so the reply is stored only when it is **explicitly shareable**. This *shared-static guard* runs on the original backend headers, **before** response rules such as `strip_set_cookie` or `ignore_cache_control`, for every static fill whose Cookie was ignored in the key:
|
||||
|
||||
| Backend reply | Result |
|
||||
|---|---|
|
||||
| Status other than 200 | not stored (`response_status`) |
|
||||
| `Set-Cookie` (even if a rule later strips it) | not stored (`response_set_cookie`) |
|
||||
| `Cache-Control: private`, `no-store` or `must-understand` (even with `ignore_cache_control`) | not stored (`response_cache_control`) |
|
||||
| `Vary: *` or `Vary: Authorization` | not stored (`response_vary`) |
|
||||
| `Content-Type: text/html` or `application/xhtml+xml` (SPA fallbacks, `/index.php/x.css`, error pages served as 200) | not stored (`response_static_dynamic`) |
|
||||
| No explicit freshness: none of `public`, `s-maxage`, `max-age>0`, a future `Expires` (heuristic `Last-Modified`, `default_ttl_seconds` and rule TTLs do not count) | not stored (`response_static_not_public`) |
|
||||
| `Vary: Cookie` | stored without the Cookie dimension only with **Ignore Vary: Cookie for public static assets** and `Cache-Control: public` (existing rule), otherwise `response_vary_cookie` |
|
||||
|
||||
When the guard refuses storage the client still receives its own response (`X-Cache: MISS`), and the next client goes to the origin. Proactive refresh of such shared objects is sent **without** the client's Cookie.
|
||||
|
||||
Disable **Ignore request cookies for static files** (globally or per Vhost) to restore the previous behavior exactly: `cookie_pass` then always bypasses, and the built-in policy reports `request_cookie`.
|
||||
|
||||
### Diagnostics
|
||||
|
||||
`X-Cache`, `X-Cache-Reason` and `Cache-Status` keep their names and formats; only new reason codes were added (`cache_rule_cookie`, `cache_miss_static_cookie`, `response_static_not_public`, `response_static_dynamic`). The source of a BYPASS can be read directly from the reason code using the precedence table above. **Test a request** additionally returns `reason_class` (`security`, `configuration`, `vcl_rule`, `vcl_cookie_guard`, `cookie`, `request_policy`, `response`, `cache`), `static_cookie_relaxed` and `shared_static_check`, and shows them in the panel.
|
||||
|
||||
### Migrating existing rules
|
||||
|
||||
- Saved rules are not changed. A `pass` rule that depends only on cookies keeps bypassing static files.
|
||||
- In the rules editor such a rule shows a hint and a **Convert to Cookie guard** button (only for request rules whose conditions are Cookie conditions, optionally combined with a method condition). Review, convert and save; no cache purge is needed because the change only allows *new* public objects.
|
||||
- For imported VCL replace `return(pass);` with `return(cookie_pass);` in Cookie/session branches only.
|
||||
- Keep private resources protected by an explicit `pass` (path rules, **Private account routes**, `cache.bypass_prefixes`) or by `Cache-Control: private` / `no-store` at the origin. A Cookie guard alone does not protect `/account/avatar.png` if the origin labels it public.
|
||||
- **Downgrade:** RustProxy 0.39.1 and older reject the unknown `cookie_pass` action when loading the configuration. Convert `cookie_pass` rules back to `pass` before installing an older binary.
|
||||
|
||||
### Limitations
|
||||
|
||||
- The decision trusts the origin's explicit public freshness for a Cookie-bearing fill. An origin that personalizes a `.css`/`.js`/image body and still sends `public` or `max-age` is misconfigured and would be shared; fix such resources with `private`/`no-store`, a path `pass` rule or `bypass_prefixes`.
|
||||
- Only statics fetched **with** a Cookie need explicit freshness; objects filled by anonymous clients follow the ordinary cache policy and are then served to logged-in clients as well.
|
||||
- Cache rules, including Cookie guards, do not apply to embedded Web Server sources (see [Web Server](WEB_SERVER.md)).
|
||||
|
||||
## Cache rules (VCL-style)
|
||||
|
||||
**Settings → Cache → Rules** holds global rules; **Vhosts → Cache → Cache rules for this vhost** holds rules for one vhost. They are built graphically ("If … Then …") and replace the most common Varnish VCL snippets without a scripting language.
|
||||
|
||||
| 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`), 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 |
|
||||
| Request | `vcl_recv`, `vcl_hash` | host, URL, path, extension, method, query parameter, request header, cookie, client IP | bypass cache (`pass`), Cookie/session guard (`cookie_pass`, see [precedence](#cache-decision-precedence-explicit-pass-and-public-static-assets)), 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 |
|
||||
|
||||
@@ -144,7 +209,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.
|
||||
- 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. A static fill fetched with a Cookie must also pass the [shared-static guard](#public-static-assets-with-a-session-cookie).
|
||||
- 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.
|
||||
|
||||
@@ -169,7 +234,7 @@ for n in 1 2 3; do
|
||||
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.
|
||||
Look for cache reason labels including `request_cookie`, `request_authorization`, `cache_rule` (explicit VCL pass), `cache_rule_cookie` (VCL Cookie guard), `response_cache_control`, `response_static_not_public`, `route_disabled` and `cache_hit` when diagnostic headers are enabled; the [precedence table](#cache-decision-precedence-explicit-pass-and-public-static-assets) maps each code to its source. A `MISS` alone does not prove the object was admitted to HOT/COLD.
|
||||
|
||||
### Browser differs from curl (HTML, cookies, reloads)
|
||||
|
||||
|
||||
Reference in new issue
Block a user