Files
RustProxy/docs/CACHE.md
T
2026-11-25 15:47:34 +01:00

386 lines
55 KiB
Markdown

# HTTP cache — HOT, COLD and invalidation
RustProxy provides an optional shared HTTP response cache with a bounded in-memory **HOT** tier and optional persistent-disk **COLD** tier. Both the global cache and a Vhost's effective policy must permit caching. **COLD storage is disabled by default**, and newly created Vhosts do not automatically cache dynamic content.
### Cache controls in Settings
The **Rules** subtab holds the conditional cache rules described in [Cache rules (VCL-style)](#cache-rules-vcl-style).
The **Static & diagnostics** subtab provides **Ignore request cookies for static files** (`cache.static_ignore_cookies`, on by default) and **Ignore Vary: Cookie for public static assets** (`cache.static_ignore_vary_cookie`, on by default), plus the allowed extensions (`cache.static_extensions`). Both options are effective only on the configured file extensions and work together: the request Cookie is excluded from the cache key, and a qualifying backend `Vary: Cookie` is removed from the stored and delivered response. Other Vary dimensions (such as `Accept-Language` or `Accept-Encoding`) remain intact. A vhost may override either option independently, or inherit the global values.
**Safety requirement:** use both options only when the complete static response (body **and headers**) is identical for all visitors regardless of Cookie. `Vary: Cookie` is a declaration that content may vary, so overriding it on a genuinely session-dependent file can expose one user's cached variant to another. RustProxy applies this override only to responses with an explicit `Cache-Control: public` directive, positive remaining freshness (without mandatory revalidation) and no `Set-Cookie`, `private`, `no-store` or invalid Vary. A zero-TTL response, including `public` with no configured fallback TTL, retains `Vary: Cookie` even if it can be stored for later revalidation. If the response is not cacheable, `Vary: Cookie` is passed through unchanged. Do not enable this optimization for user-specific downloads, generated PDFs, account JSON, or any path where Flask or another origin changes content according to a session cookie; prefer removing the needless `Vary: Cookie` at the origin where possible.
### Ready-made quick rules library
The **Add from template** dropdown is grouped by scenario. **Browse scenarios** opens a searchable panel with descriptions and one-click **Add** buttons for ready-made request, response and delivery rules. The library includes common application sessions, WordPress/WooCommerce, Django, Laravel, Auth.js, API and private routes, SSE/webhooks, TTL for verified public content and defensive headers. Some scenarios add multiple rules. Templates with a risk of unexpected shared-cache reuse are **disabled until reviewed**. The CDN and selective parent-domain cookie templates stay separate. See [Quick rules template library](CACHE_TEMPLATE_LIBRARY.md) for categories, order, defaults and tests. Adding rules changes the draft; save settings before relying on them.
### CDN security cookies (opt-in VCL template)
The cache rules template menu now includes **CDN technical cookies** for Cloudflare (`__cf_bm`, `cf_clearance`, `_cfuvid`, `__cfruid`, `__cfseq`) and Akamai (`_abck`, `ak_bmsc`, `bm_sz`, `bm_sv`). It bypasses non-GET/HEAD methods, restricted application paths and `Authorization`. It strips the entire Cookie header **only if all Cookie fields contain allowlisted technical cookies**, and bypasses any request with a remaining Cookie (for example `session`, `wordpress_logged_in_*`, CSRF tokens or other personalized cookies). The source equivalent is [`examples/vcl/cdn-technical-cookies.vcl`](../examples/vcl/cdn-technical-cookies.vcl). Import it only after reviewing warnings; enable the graphical template only on tested public Vhosts. Some challenge cookies (especially `cf_clearance`, `_abck` and `ak_bmsc`) are important to specific origin/CDN configurations; removing them can break a challenge flow. **This is not turned on automatically for existing Vhosts.**
### Parent-domain cookies: opt-in per-Vhost name filtering
A parent domain may set `Set-Cookie: name=value; Domain=.example.test`, making browsers send it to subdomains. The incoming `Cookie` header **does not include the Domain attribute**: RustProxy cannot distinguish the parent cookie from a cookie with the same name set by this Vhost. Prefer configuring host-only cookies (omit `Domain`) at the issuing application.
Two **separate** opt-in templates remain available in the Vhost cache-rule editor:
1. **Vhost: remove selected parent-domain cookies** (inserted **disabled**): the operator supplies verified comma-separated cookie names or trailing-`*` prefixes in the `Remove selected cookies` action, replacing `REPLACE_WITH_VERIFIED_PARENT_COOKIE_NAME`. Only matching names are removed from incoming GET/HEAD requests; every other cookie, including the application's session, stays intact. The rule has **no** `return(hash)` and **does not stop** subsequent cache rules. It excludes Authorization and example private paths; review the path list for your application. The example is [`examples/vcl/public-vhost-remove-parent-cookies.vcl`](../examples/vcl/public-vhost-remove-parent-cookies.vcl).
2. **CDN technical cookies** (independent, unchanged): its safe-method/private-path/Authorization guards, its anchored whole-header CDN cookie allowlist and **CDN: bypass remaining cookies** continue to run after parent cookie removal. It never treats a remaining session cookie as a CDN cookie. See [`examples/vcl/cdn-technical-cookies.vcl`](../examples/vcl/cdn-technical-cookies.vcl).
**Order:** place the parent-cookie rule **above** `CDN: remove ONLY technical cookies` and especially **above** `CDN: bypass remaining cookies`; leave the CDN guard rules active at the top. **Delete/disable any old `Public vhost: ignore inherited cookies` rule that uses `strip_cookies: keep=[]` + `lookup`**. Updating the binary does not remove existing saved rules. Never add an application session cookie, login token, CSRF token, locale/personalization cookie or sticky-session identifier to the parent-name list. The only supported wildcard is a **single trailing `*`** (a case-sensitive prefix). For example, `SESS*` or `SSESS*` can discard Drupal 6 cookies from an unrelated parent application, but **only if this Vhost never relies on that cookie family**. Interior wildcards, `*` alone, prefixes shorter than 3 characters and arbitrary regexes are rejected. If the same cookie name or prefix can belong to the parent **and** this application, use host-only cookies at the issuer instead of the removal rule.
Resulting request behavior on public pages: `Cookie: parent_marketing=1` (listed) → stripped → cache eligible; `Cookie: parent_marketing=1; __cf_bm=2` → parent removed by this rule, then CDN removed by its separate template → eligible; `Cookie: parent_marketing=1; app_session=abc` → only parent removed, session retained → CDN remaining-cookie rule **BYPASS**; POST, Authorization and private paths are not rewritten by the new template. Verify each using **Cache rule tester** and live `X-Cache-Reason` headers. Responses with `Set-Cookie`, `private` or `no-store` still cannot enter shared storage. The origin's `Vary: Cookie` stays intact and is evaluated against the **remaining** Cookie value. Configure logged-in origin responses as `private, no-store` as defense in depth.
The import syntax `remove_req_cookies("name1", "name2");` is a **RustProxy-specific VCL extension**, not stock Varnish syntax. It performs exact, case-sensitive name matching or a case-sensitive prefix match for a **single trailing `*`**, preserves other cookies, and refuses to rewrite malformed Cookie fields. The graphical `Remove selected cookies` action uses the same implementation. For a Drupal 6 parent domain with local `session` cookies, see [`examples/vcl/drupal6-parent-session-cookies.vcl`](../examples/vcl/drupal6-parent-session-cookies.vcl). This new action is not the dangerous `Strip cookies` / "keep" operation, which can remove other cookies.
**Do not extend** `Ignore Vary: Cookie for public static assets` to a general "Ignore Vary" control. `Accept-Encoding`, `Accept-Language`, `Accept`, `Origin`, `User-Agent` and custom response-specific dimensions can change bytes, permissions or CORS headers. Keep the response's actual dimensions and use the existing safe normalization of recognized list fields below, or remove an unnecessary `Vary` at the origin only after proving the response is invariant. A VCL `unset beresp.http.Vary` is *possible*, but it is not the equivalent of a guarded static-file optimization.
## `Vary` matching (RFC 9111 §4.1)
Cached variants use the response's `Vary` field names together with the original request's nominated fields. Reuse requires a match in **every** retained `Vary` dimension; `Vary: *` is never reusable. An absent request field is not equivalent to a present but empty field.
To avoid unnecessary variants, RustProxy normalizes optional whitespace around commas, joins repeated header lines **only** for known comma-list fields, and preserves quoted strings. For valid `Accept-Language`, `Accept-Encoding` and `Accept-Charset` values it also normalizes case-insensitive tokens and equivalent `q` weights (`q=1` and an omitted weight are equivalent). `Accept` media type/subtype casing is normalized without changing case-sensitive parameter values. List order remains intact; values of `Cookie`, `User-Agent` and other opaque/custom fields are not parsed or reordered. Unsupported or malformed values fall back to conservative bytewise matching (aside from outer HTTP whitespace). This is **deliberately limited semantic normalization**, not a promise to reinterpret every possible extension header.
The corrected key algorithm uses a new internal variant-key domain. On upgrading an existing installation to the updated **0.38.7** sources, previously persisted COLD variants keyed by the older algorithm will miss and be repopulated; unvaried cached responses do not change. These cold misses are intentional to avoid unsafe cross-version reuse. No configuration changes or cache clearing are required.
## Enable caching safely
1. Open **Settings → Cache**, enable the global cache and choose memory limits. Enable COLD only if you want durable disk storage and have enough private disk capacity.
2. On the appropriate Vhost, enable cache for public, repeatable responses. Restrict or disable it for login, personalized pages, uploads, APIs and responses carrying secrets.
3. Ensure the origin supplies a valid public freshness policy, or configure a safe default TTL where supported. `Cache-Control: private` and `no-store` must prevent shared storage.
4. Optionally enable HIT-only diagnostics. Send repeated identical requests using `curl`, then inspect **Cache → Domains / Stored objects** for `MISS → HIT`.
5. Review **Varnish-compatible cache policy**, enabled by default, then check TTL, revalidation and invalidation after updating the origin's content or configuration.
## Varnish-compatible cache policy
**Settings → Cache → Varnish-compatible cache policy** (`cache.varnish_compatible`, **enabled by default**) avoids needless cache replacement on browser hard reloads. On a fresh object it ignores only the client's `Cache-Control: no-cache`, `max-age=0` and `Pragma: no-cache` for cache **lookup/freshness**. It does not remove or modify these request headers when fetching from the origin, and it does not alter cache identity or request conditionals.
Set **Default grace (seconds)** in Settings → Cache (default **60**, range 0..604800). This affects only eligible objects in compatibility mode and never overwrites explicit origin `stale-while-revalidate`, including `=0`. Use the adjacent **i** information icon for the short operator explanation (PL/EN). Disabling the option restores the original strict client reload semantics. Changing modes invalidates currently stored representations across HOT/COLD so they are refilled under one consistent policy; no process restart is needed. Existing JSON configurations with no field inherit `true`. The setting also applies to eligible resources of the embedded Web Server.
| Condition | Enabled: Varnish-style optimized, RustProxy protections retained | Disabled: legacy strict |
|---|---|---|
| Client `no-cache`, `max-age=0`, `Pragma: no-cache` | **Fresh HIT** without replacing object or resetting `Age` / HIT counter | Can force origin revalidation (and `200` replacement without an origin validator) |
| Client `no-store` | **BYPASS**: do not use or populate a shared representation | Same |
| 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 `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 |
| 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:** 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 the [practical VCL traffic cookbook](VCL_TRAFFIC_COOKBOOK.md) for examples, expected request outcomes and curl tests; [VCL compatibility and header overrides](VCL.md) and the [exhaustive support matrix](VCL_SUPPORT_MATRIX.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.
To verify with real GET requests (not `curl -I -X GET`):
```bash
URL=https://example.com/ui/style.css
curl -sS --compressed -D - -o /dev/null "$URL" | grep -iE '^(HTTP/|age:|x-cache:|x-cache-hits:|x-cache-reason:)'
curl -sS --compressed -H 'Cache-Control: no-cache' -H 'Pragma: no-cache' -D - -o /dev/null "$URL" | grep -iE '^(HTTP/|age:|x-cache:|x-cache-hits:|x-cache-reason:)'
curl -sS --compressed -D - -o /dev/null "$URL" | grep -iE '^(HTTP/|age:|x-cache:|x-cache-hits:|x-cache-reason:)'
```
With the policy enabled, the middle request stays `HIT` if the entry is fresh. Check safeguards separately: an uncached URL with `Cache-Control: only-if-cached` must return **504** without reaching the backend; a stale `only-if-cached` HIT must **not** start background validation/proactive refresh. `min-fresh` and `max-stale` still constrain stale reuse: an explicit `max-stale=0` must not be bypassed by the configured implicit grace. `Cache-Control: no-store` must bypass an existing fresh entry.
## Vhost editor options
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.
In corrected 0.42.0, forced-cache keys always partition by both `Cookie` and
`Authorization` **before lookup**. Missing, empty and nonempty fields remain
distinct, including when one credential appears only after another variant was
cached. Explicit VCL/HTTP-policy lookup partitions Cookie in the same way;
Authorization still bypasses unless the separate force option admits it.
The forwarded values after the existing credential filter and supported request
edits are used. An entirely empty input Cookie field is still removed by the
admin-cookie filter; a valid empty cookie such as `session=` remains distinct
from no Cookie. Responses add the corresponding `Vary` dimensions even when the
request lacks those fields. Explicit later delivery-header overrides retain
their documented behavior and must preserve dimensions needed downstream.
These keys use a new internal namespace, so older forced/VCL-lookup HOT/COLD
entries cannot satisfy the corrected lookups; they may remain on disk until
normal eviction or cleanup. Other cache keys and the COLD file format remain
compatible. Credential-partitioned fills do not schedule proactive background
refresh; ordinary foreground validation retains the matching request context.
Response privacy exclusions and explicit VCL `return(pass)` still apply.
## 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`), 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 |
- 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 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.
- 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*. 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
- 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. 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.
## Freshness and diagnostics
| State | Interpretation |
|---|---|
| `MISS` | No suitable fresh cached representation was found; the origin was consulted. The response may still be ineligible for storage. |
| `HIT` | A matching stored object was reused. |
| `BYPASS` | Cache was disabled or a policy intentionally skipped it (for example authorization, cookies or a path exclusion). |
| Revalidated | An existing representation was checked against the origin; a `304` can retain the body. |
`Age` is total HTTP age, not only the time spent in RustProxy. The optional `X-Cache-Resident-Age` reports the cache residency interval. Debug headers such as `X-Cache`, `X-Cache-Hits` and reason labels are optional and should be enabled deliberately. With `varnish_compatible=true`, browser hard reloads do not force revalidation while an object remains fresh. In strict mode hard reloads can force origin revalidation; compare with `curl` when investigating.
Example, replacing the listener and Host values with yours:
```bash
for n in 1 2 3; do
curl -sS -D - -o /dev/null -H 'Host: app.example.com' \
http://127.0.0.1:8080/public.css
sleep 2
done
```
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)
Compare **two consecutive normal GET navigations** to exactly the same URL and inspect **Network → request headers** and **response headers** in the browser. Use `X-Cache-Reason` to distinguish `request_cookie` (BYPASS) from `request_no_cache` / `request_max_age` (revalidation) and from `cache_miss` (no matching stored variant). A browser may send session/analytics cookies absent from a plain curl request. `Vary: Cookie` is an explicit instruction to partition cached representations by the complete incoming Cookie header; a VCL rule stripping *approved technical cookies* from the request does not remove application cookies or automatically suppress `Vary: Cookie` for HTML. Do not remove the latter or strip session cookies unless the application guarantees that both headers and body are identical for every visitor.
For a faithful command-line comparison, use **Copy as cURL** for a browser request and repeat the resulting command without changing its Cookie, `Accept-Encoding`, URL or request cache directives. Then test a second invocation with only irrelevant technical cookies omitted, if appropriate. Different compression/`Vary` representations may each have their own initial MISS. For manual reloads, check **Disable cache** in DevTools and `Cache-Control`/`Pragma` on the *request*. With the default `varnish_compatible=true`, only the supported reload directives are ignored for fresh lookup; `no-store`, Cookie bypass and credential policy are not ignored.
An eligible uncached `HEAD` is forwarded upstream as `GET` and can populate the same cache entry as a future GET. RustProxy returns the HEAD headers and drains the fetched body **without delivering it to the HEAD client**; the fill is asynchronous and bounded by the configured cache object size and a 30-second deadline. A GET requested before this fill has completed may still show MISS or wait for the in-flight fill; if the body exceeds the size/deadline or fails, no object is stored. HEAD responses to requests which bypass the cache are **not** drained by this mechanism.
### 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.
For example, with an upstream HIT and a RustProxy HIT:
```http
Cache-Status: BackendCache; hit; ttl=500
Cache-Status: RustProxy; hit; ttl=482; detail="cache_hit"
X-Cache: HIT
```
On first fill, RustProxy uses `RustProxy; fwd=miss; detail="cache_miss"` (unless another forwarding reason applies). A cache policy BYPASS uses `fwd=bypass`, and reuse of a stored body following origin `304` validation is reported as `fwd=stale; fwd-status=304`, **not** a fresh unforwarded RFC 9211 HIT. The existing `X-Cache: HIT` for that validation remains for legacy monitoring compatibility. The `ttl` parameter counts remaining seconds for a RustProxy HIT, not the upstream's TTL, and `detail` is a fixed RustProxy reason code. The optional `transformed` extension on RustProxy's member is applied only to its own entry.
**Legacy collisions:** `X-Cache`, `X-Cache-Hits`, `X-Cache-Reason` and `X-Cache-Resident-Age` are non-standard response fields. They do not define interoperable append/list semantics. When RustProxy is configured to emit a particular field, it owns that field and copies all origin values (if any) into `X-Upstream-Cache`, `X-Upstream-Cache-Hits`, `X-Upstream-Cache-Reason`, or `X-Upstream-Cache-Resident-Age` respectively. For example:
```http
X-Cache: HIT
X-Upstream-Cache: MISS
Cache-Status: BackendCache; fwd=miss
Cache-Status: RustProxy; hit; ttl=482; detail="cache_hit"
```
Here, the upstream MISS is the **original backend state when RustProxy filled the object**; it is not a fresh backend measurement on every RustProxy HIT. `X-Cache-Status` is forwarded unchanged because RustProxy does not generate that field. The `X-Upstream-*` aliases are a compatibility convenience, **not RFC 9211**; for new integrations use `Cache-Status` instead. Upstream headers are relayed as provided, without verifying the upstream's diagnostic accuracy.
**Display switches:** `Expose cache status`, `Expose cache hits`, `Expose cache resident age`, `Expose Cache-Status` and `Only on HIT` control **only RustProxy-generated headers**, not origin-supplied headers. Even when RustProxy caching is disabled, or a MISS/BYPASS is hidden by the Only on HIT option, backend-provided cache diagnostics remain visible. The `Via` header is governed separately by its configured cache policy. Backend diagnostics persist with eligible cached objects in HOT and COLD; responses which were never cacheable are still forwarded with their upstream fields intact.
To verify on a cacheable URL, use **GET** twice, without forced reload:
```bash
URL=https://example.com/public.css
for n in 1 2; do
curl -sS -D - -o /dev/null "$URL" | grep -iE '^(HTTP/|age:|cache-status:|x-cache:|x-upstream-cache:|x-cache-hits:|x-upstream-cache-hits:)'
done
```
The initial request can show `RustProxy; fwd=miss`; an eligible repeat should show `RustProxy; hit; ttl=...`. If the origin sends no `Cache-Status`, there is no upstream member to display. If RustProxy diagnostic output is off, any visible `Cache-Status` is from upstream; absence of a RustProxy member is expected. The actual cache outcome should also be checked in server request logs.
## Detailed cache status: STALE and REVALIDATED
Two kinds of responses come from the cache but are not plain hits:
- **STALE** — served past its freshness: Varnish grace, `stale-while-revalidate`, `max-stale`, `stale-if-error` while the origin fails, or a request-collapse timeout.
- **REVALIDATED** — the stored object was confirmed by the origin with `304 Not Modified`.
Where they show:
| Place | Value |
|---|---|
| `Server-Timing` cache metric | always `STALE` / `REVALIDATED` |
| access log `cache` field, log filter and `rust-proxy logs` | always `STALE` / `REVALIDATED` (before 0.38.2: `HIT`); `cache_reason` gives the exact cause |
| `X-Cache` | `HIT` by default; `STALE` / `REVALIDATED` with **X-Cache shows STALE and REVALIDATED instead of HIT** (`cache.expose_detailed_status`, also per vhost) |
| Cache dashboard | counted as HIT for the hit ratio; the request line adds `· N STALE · N REVALIDATED` (also `stale` and `revalidated` per domain in `/api/cache`) |
Panel HIT/MISS/BYPASS counts are final request outcomes, recorded once at response headers. STALE and REVALIDATED are HIT subcategories; collapsed requests served from the newly filled cache are HIT, even if their first lookup missed. Background refresh reasons remain visible as maintenance events without incrementing client HIT. Technical lookup counters remain separate and may record several operations per request. Domain counters reset when a cache representation change clears their catalog; global request counters reset only on service restart.
A growing STALE count while the origin is down means RustProxy is answering from cache instead of returning errors. `Only on HIT` treats STALE and REVALIDATED as hits. `X-Cache` stays `HIT` by default because monitoring scripts often match on it.
## Server-Timing
With **Expose Server-Timing diagnostics** (`timing_headers: true` on the vhost) RustProxy adds one `Server-Timing` field. Browsers show it in the developer tools (Network → Timing) and RUM tools read it through `PerformanceServerTiming`.
```http
Server-Timing: app;dur=7
Server-Timing: proxy;dur=2.31, upstream;dur=1.94, proxy-cache;desc="MISS"
```
| Metric | Meaning |
|---|---|
| `proxy;dur` | Total time in RustProxy until the response headers, in milliseconds. |
| `upstream;dur` | Time from sending the request to the backend until its response headers. Absent when the backend was not contacted. |
| `proxy-cache;desc` | `HIT`, `MISS`, `BYPASS`, `STALE` or `REVALIDATED` (see above). Absent when no cache decision was made. |
**Metric names** (`timing_header_names`, panel: **Server-Timing metric names**):
| Value | Names | When |
|---|---|---|
| `standard` (default) | `proxy`, `upstream`, `proxy-cache` | RustProxy as a reverse proxy or load balancer in front of the application. The names do not collide with a CDN in front of RustProxy (Cloudflare, Akamai, Fastly add their own `edge`, `origin`, `cdn-cache`, where *origin* means RustProxy) nor with an application's own `cache` metric. |
| `cdn` | `edge`, `origin`, `cdn-cache` | RustProxy is the outermost, CDN-like layer and a RUM tool expects the Akamai mPulse names. Do not use with a CDN in front of RustProxy. |
| `legacy` | `proxy`, `origin`, `cache` | Names used before 0.38.2, for existing dashboards. |
- On a MISS or BYPASS the origin's own `Server-Timing` metrics are kept and RustProxy's field is appended after them. With several RustProxy hops (edge → front → application) every hop appends its own field, so the inner hop's cache result stays visible.
- On a response served from the cache (`HIT`, `STALE`, `REVALIDATED`) the stored `Server-Timing` of the origin is removed, because it describes the request that filled the cache, not this one. This also applies when `timing_headers` is off.
- Scripts on the same origin can always read `Server-Timing`. For scripts on another origin (a RUM collector, an assets domain) list those origins in **Timing-Allow-Origin** (`timing_allow_origin: ["https://app.example.com"]`, or `["*"]`); the header is only sent together with Server-Timing.
- Turn Server-Timing off on public production sites if response timings should not be exposed.
## Advanced behavior
- **Budget limits:** HOT RAM capacity, object count/size, transient fill memory and optional COLD byte/object limits. Configure based on real workload and monitor disk/RSS.
- **HOT/COLD movement:** entries may be demoted, recovered or expired; a periodic/explicit COLD cleanup is available. Cache storage is not a permanent archive.
- **Request collapsing:** eligible concurrent MISS requests can share a bounded fill, limiting origin bursts.
- **Stale-if-error and refresh:** conditional options can help on eligible backend failures, but are not an unconditional stale-serving guarantee. Web Server local-file validation has a distinct policy.
- **Compression/transformation:** cached variants and validators must remain compatible with client encoding and content-modification settings.
## Clear or invalidate content
Authenticated Cache page/API operations can purge selected entries, domains or larger scopes. The optional public HTTP `PURGE`/`BAN` interface is **disabled by default**. Enable it only by listing trusted client IPs/CIDRs under **Settings → Cache → HTTP BAN / PURGE IP allowlist**; operations are additionally subject to Vhost binding and normal access controls. `PURGE` addresses an exact URL; `BAN` applies the supported bounded matching rules. Never allow untrusted Internet clients to purge all tenants' objects.
Which configuration saves invalidate stored objects:
| Change | Effect on HOT/COLD |
|---|---|
| Global cache **tuning**: memory and object limits (`max_bytes`, `max_entries`, `max_object_bytes`, `transient_max_bytes`, `cold_queue_max_bytes`, `hot_eviction_max_objects`), HOT auto-trim, COLD demotion/GC/limits (`cold_after_seconds`, `cold_on_*`, `cold_max_*`, `cold_gc_*`), request coalescing (`collapse_*`), `stale_if_error_*`, proactive refresh, memory/COLD presets, diagnostic headers, `via_header`, bypass paths/query, HTTP invalidation CIDRs | **Nothing is purged** (since 0.39.2). New values apply to the next requests; a lowered memory/entry limit evicts least-recently-used objects immediately. |
| Global **representation or privacy** settings: cache on/off, `varnish_compatible`, TTL/grace, static Cookie options and extensions, global cache rules, `cold_enabled`/`cold_path`, transformations, global headers/forwarding, Web Services, PHP-FPM profiles | **All** HOT/COLD objects of every Vhost are invalidated. |
| Vhost content settings: hosts, routes, backends' URLs, Vhost cache settings and rules | Only that Vhost's objects are invalidated. |
| Vhost operational settings: TLS, ACL, rate limit, timeouts, load balancing, weights/health checks, authentication, diagnostic headers | Nothing is purged. |
COLD entries carry the same fingerprint, so after a restart objects survive tuning-only changes and are discarded after representation/privacy changes. Validate the cache after configuration edits and during upgrades; earlier persistent cache entries may need refilling following format/compatibility transitions.
## Troubleshooting
- **Always BYPASS:** check both cache enable switches, login/cookies, exclusion rules, methods, Tinyauth and sticky sessions.
- **MISS never becomes HIT:** check response `Cache-Control`, status, object size, `Vary`, `Set-Cookie`, incomplete origin streams and whether the same scheme/Host/query is used.
- **Content unexpectedly old:** inspect Age, TTL, validators, stale rules and previous invalidation; purge only affected content after confirming its identity.
- **Memory/disk pressure:** review HOT/COLD budgets and cleanup, rather than increasing limits without measurements.
See [Monitoring](MONITORING.md) for cache telemetry and [Security](SECURITY.md) for privacy boundaries.