22 KiB
Cache rule template library: all 42 scenarios
Applies to RustProxy 0.39.2. This reference documents the 42 scenarios shipped by the graphical Add from template... and Browse scenarios controls. It describes the rules actually generated by src/admin/web/cache-rules.js, including their initial enabled state, exact matching scope, effects and limitations. The seven sections below follow the panel's category order.
These are graphical cache rules, not scripts executed by a Varnish VCL engine. The panel can export a readable VCL preview, but that export is not a lossless rule backup. For the VCL import subset, see VCL.md; for copyable VCL examples, see the traffic cookbook.
Add, configure and activate a template
- Open Vhost -> Cache -> Cache rules (including a Docker-generated Vhost), or Settings -> Cache -> Rules for global rules. Only Vhost editors offer the parent-domain cookie template.
- Choose Add from template..., or open Browse scenarios, search by name/description and click Add. A scenario inserts one or more ordinary rules. Adding does not save the configuration.
- Expand the new rules. Check the match mode (all vs any), paths, cookie names, headers and TTL. Enable rules marked Off only after adaptation. Review their order relative to other Vhost and global rules.
- Use Test a request with anonymous, session-cookie,
Authorizationand sensitive-path examples. Save the settings, test with real GET requests and inspectX-Cache,X-Cache-Reason,AgeandCache-Status. - Purge existing cache entries after changing privacy or representation boundaries. New no-store or BYPASS rules cannot retrospectively remove already-stored objects.
A template is On if its generated rule(s) are enabled when inserted; Off means deliberate opt-in is required. Request rules alter or bypass a request before cache lookup; response rules control backend response storage; deliver rules change outgoing response headers, including on HIT. Deliver-only Cache-Control: no-store does not disable RustProxy's shared cache. Multi-rule scenarios insert all their rules together; exceeding the 128-rule limit rejects the group.
1. Security and private content (15 scenarios)
| Template (internal key) | Rules / default | Match and precise behavior | Configuration / caveat |
|---|---|---|---|
Methods other than GET/HEAD (safemethods) |
1 request, On | Method is not GET or HEAD -> pass (BYPASS). |
Usually a safe guard for forms and writes. Other method restrictions still come from RustProxy's normal cache policy. |
Authorization (authbypass) |
1 request, On | An Authorization request header exists -> pass. |
Applies to any route. Do not try to compensate by removing the header. |
Any Cookie (cookiepass) |
1 request, On | Any Cookie header exists -> cookie_pass (Cookie guard: BYPASS for pages; public static assets may still be cached, see below). |
Conservative for unknown apps; place after a selective parent-domain/CDN cleanup if those cookies should be ignored. |
Common session cookies (sessioncookies) |
1 request, On | Cookie header contains an exact cookie-name boundary for session, sessionid, PHPSESSID, laravel_session, connect.sid or sid -> cookie_pass. |
Not an exhaustive session list. Add app-specific names or use Any Cookie as a fallback. |
Private account routes (privateroutes) |
3: request + response + deliver, On | Paths starting with a complete segment admin, auth, login, logout, user, users, account, profile, settings, dashboard, cart, checkout, orders, billing or payment: pass, block storage and deliver Cache-Control: private, no-store. |
Review locale prefixes, custom account URLs and API routes. Purge previously cached responses. |
Preview or draft links (preview) |
1 request, On | Path segment /preview or /draft, or a preview/draft query parameter -> pass. |
Add other preview token names as needed. A query parameter's mere presence is sufficient. |
Cart / checkout / payments (checkout) |
1 request, On | /cart, /checkout, /payment, /billing, /order, /orders (and descendants) -> pass. |
Does not by itself send browser no-store; configure application/private responses accordingly. |
Webhooks / callbacks (webhooks) |
1 request, On | /webhook, /webhooks, /callback, /callbacks or /hooks (and descendants) -> pass. |
Adapt nonstandard callback endpoints. This changes cache routing, not webhook authentication. |
Health and metrics (healthchecks) |
1 request, On | /health, /healthz, /readyz, /livez, /metrics, /status -> pass. |
Does not block public access to those endpoints; protect sensitive metrics separately. |
GraphQL (graphql) |
1 request, On | /graphql and descendants -> pass even for GET requests. |
Conservative when GraphQL queries can depend on the user. Other GraphQL endpoint paths need separate rules. |
SSE and WebSocket (streaming) |
1 request, On | Accept contains text/event-stream or an Upgrade request header exists -> pass. |
Streaming/upgrades should not be served from a normal HTTP object cache. |
Signed query URLs (signedurls) |
1 request, On | Query contains any of token, access_token, signature, sig, auth_token -> pass. |
Update the list for the app's signed parameter names. The rule matches name presence, not token validity. |
All HTML no-store (nocachehtml) |
2: response + deliver, On | Backend Content-Type begins text/html: prevent shared-cache storage and deliver browser Cache-Control: no-store. |
No request-stage pass is added. Purge old HTML objects to avoid serving pre-existing HITs. |
Private API (privateapi) |
3: request + response + deliver, On | Path starts with /api/private/: pass, prevent storage and send Cache-Control: private, no-store. |
Does not automatically cover /api/private without /, /v1/... or other private API prefixes. |
Private downloads (privatedownloads) |
2: request + deliver, Off | Example prefix /private-downloads/: pass plus browser Cache-Control: private, no-store. |
Replace the sample prefix, enable both rules and purge older objects. It adds no response-stage no_store rule. |
These templates are cache protections, not authentication or authorization. The origin must still enforce access control, and should return Cache-Control: private, no-store for user-specific responses.
2. CMS and framework sessions (7 scenarios)
All seven insert request-stage rules, enabled by default. Cookie triggers use cookie_pass (Cookie/session guard); path triggers use an explicit pass, so WordPress and WooCommerce insert two rules. They retain cookies and forward them to the backend; none rewrites a session cookie.
| Template (internal key) | Trigger | Use and adjustments |
|---|---|---|
WordPress (wordpress) |
Path begins /wp-admin, /wp-login.php, /xmlrpc.php or /wp-json; or Cookie contains wordpress_logged_in_, comment_author_, woocommerce_items_in_cart or wp-postpass_. |
Protects dashboard, login, REST endpoints and common session/comment cookies. Check custom login and REST routes. |
WooCommerce (woocommerce) |
/cart, /checkout, /my-account; or Cookie has wordpress_logged_in_*, woocommerce_items_in_cart, wp_woocommerce_session_* or woocommerce_cart_hash. |
Protect cart/account/session traffic. Add localized/custom checkout routes and session-cookie names. |
Django (django) |
Named Cookie sessionid exists. |
Adjust the exact name if the application overrides SESSION_COOKIE_NAME. Does not match a differently named session. |
Laravel / PHP (laravel) |
Cookie laravel_session or PHPSESSID exists. |
Account for custom PHP/Laravel session names; may need CSRF/private-path rules. |
Auth.js / NextAuth (authjs) |
Cookie authjs.session-token or next-auth.session-token, optionally prefixed with __Secure-. |
Extend for other Auth.js token/session cookie names and custom prefixes. |
ASP.NET (aspnet) |
Cookie .AspNetCore.Cookies or ASP.NET_SessionId exists. |
Adapt to the app's authentication scheme/custom cookie names. |
Drupal (drupal) |
Cookie name has SESS or SSESS followed by one or more hexadecimal characters. |
Captures common Drupal session names; confirm site-specific prefixes and authenticated routes. |
A framework template recognizes only the listed paths or cookie names. Where a session could use any other cookie name, keep the conservative Any Cookie guard (after any verified cookie cleanup) until the app has been audited.
3. CDN and inherited cookies (2 independent scenarios)
| Template (internal key) | Rules / default | Exact effect | Deployment notes |
|---|---|---|---|
CDN technical cookies (cdn) |
5 request rules, all On | pass non-GET/HEAD; pass /admin, /api, /auth, /login, /logout, /panel, /konto, /dashboard; pass Authorization; strip the entire Cookie header only if every cookie name belongs to the fixed Cloudflare/Akamai technical list; then cookie_pass if any Cookie remains. |
Do not replace the anchored allowlist with a contains/substring match. Cookie names: __cf_bm, cf_clearance, _cfuvid, __cfruid, __cfseq, _abck, ak_bmsc, bm_sz, bm_sv. Use only if those values are irrelevant to the origin's representation. |
Selected parent-domain cookies (publiccookies) |
1 request rule, Off; Vhost-only | Only on GET/HEAD with Cookie, without Authorization and outside specified private prefixes: remove only selected exact cookie names or trailing-* prefixes entered by the operator; no forced cache lookup and no stop. |
Replace REPLACE_WITH_VERIFIED_PARENT_COOKIE_NAME with verified names or prefixes (e.g. SESS* for an unrelated Drupal 6 parent, never if this Vhost uses Drupal sessions). Other cookies remain and can trigger the CDN remaining-cookie pass guard. |
Safe order for a Vhost using both:
- CDN method, private-path and Authorization
passguards. - Selected parent-domain cookies (only verified names; enabled after review).
- CDN technical-cookie stripping (only technical-only Cookie headers).
- CDN BYPASS remaining cookies guard.
A separate Any Cookie guard should also follow the cookie cleanup if used. The parent-domain template is automatically inserted before existing CDN stripping/remaining-cookie rules within the same editor; it does not rearrange saved rules in another scope. Vhost-stage rules are evaluated ahead of applicable global rules. Never enable an old ignore all inherited cookies rule that calls strip_cookies for every name and then forces lookup.
Why names must be verified: request Cookie carries names and values, not the Domain attribute that originally set the cookie. RustProxy cannot automatically tell whether it came from a parent host. If the parent site and application use the same cookie name for different purposes, name-based deletion is unsafe. Prefer host-only cookies at the issuer or an explicit per-route design instead. Removing a Cookie changes both the cache decision and what the backend receives.
For copyable VCL syntax, see parent-domain cookie removal, public-vhost-remove-parent-cookies.vcl and cdn-technical-cookies.vcl. The selective remove_req_cookies(...) instruction accepts exact names and a single trailing wildcard (prefix*) and is a RustProxy extension, not standard Varnish VCL. For Drupal 6 parent cookies see drupal6-parent-session-cookies.vcl.
4. Public content and cache TTL (10 scenarios)
Response-stage TTL rules only affect otherwise eligible responses. They do not override private/no-store cache policy, Set-Cookie, Vary, authentication, object limits or the HTTP 200 only storage restriction in RustProxy 0.39.2. They do not necessarily change Cache-Control seen by a browser.
| Template (internal key) | Rules / default | Match and actions | Enable only when... |
|---|---|---|---|
Public JSON API (publicjson) |
1 response, Off | Prefix /api/public/, status 200 and Content-Type: application/json* -> TTL 60 s, grace 30 s. |
API payload is identical for all eligible users and its Vary/cache headers are correct. |
Blog / catalog HTML (publicpages) |
1 response, Off | /blog, /news, /articles, /catalog, /products and descendants; status 200, text/html* -> TTL 300 s, grace 60 s. |
Pages do not contain per-user names, carts, account data or other personalized fragments. |
RSS / Atom (feeds) |
1 response, Off | /feed, /rss, /rss.xml, /atom.xml and descendants; status 200 -> TTL 600 s. |
Feeds are public; review any authenticated/custom feed endpoints. |
Sitemap XML (sitemap) |
1 response, Off | /sitemap.xml, /sitemap_index.xml or /sitemap/...; status 200 -> TTL 3600 s. |
Sitemap URLs are stable/public and updates can tolerate up to an hour of caching. |
Filename-hashed assets (hashedassets) |
1 response, Off | Under /assets/, /static/, /build/ with a hash-like filename segment (at least 8 allowed characters), known JS/CSS/image/font extension and status 200 -> TTL 31,536,000 s (1 year). |
Filenames really change on content updates; the pattern itself cannot prove immutability. |
Images (imagecache) |
1 response, Off | Extensions png, jpg, jpeg, webp, avif, gif, svg; status 200 -> TTL 86,400 s (1 day). |
No private avatars, signed assets or user-specific image URLs are matched. |
Fonts (fontcache) |
1 response, Off | Extensions woff, woff2, ttf, otf; status 200 -> TTL 2,592,000 s (30 days). |
Font files and licensing/access requirements allow public reuse. |
Search results (searchttl) |
1 response, Off | Path starts with /search and status 200 -> TTL 15 s. |
Responses are genuinely public. Prefix also matches similar paths such as /searchable; narrow it if needed. |
Static files: strip cookies + TTL (static) |
2: request + response, On | Known static extensions: remove all request cookies. On status 200 set TTL 2,592,000 s (30 days) and remove backend Set-Cookie. |
Audit carefully: this existing template changes what the origin receives and can be unsafe for protected/downloaded resources whose path looks static. |
Remove tracking query params (tracking) |
1 request, On | Remove utm_*, fbclid, gclid, msclkid, mc_cid, mc_eid, _ga from the request URL/cache key. |
The backend never uses those parameters to choose response contents, permissions or redirects. |
Important distinction: the static and tracking legacy templates start On, unlike the eight newly introduced TTL scenarios. Review them when the Vhost serves protected or parameter-dependent resources.
5. Cache-key variants (1 scenario)
| Template (internal key) | Rules / default | Behavior | Limitation |
|---|---|---|---|
Language cookie (language) |
1 request, On | Add the named lang cookie to RustProxy's internal cache variant key (hash_cookie). |
This does not bypass the ordinary request-cookie restriction and does not automatically generate downstream Vary: Cookie. Align the origin's representation policy and actual language cookie name. |
6. Outgoing response headers (6 scenarios)
These run at the deliver stage. Unless accompanied by request/response rules, they do not affect whether RustProxy reads or writes shared cache objects.
| Template (internal key) | Rules / default | Match and action | Limitations |
|---|---|---|---|
Hide X-Powered-By (headers) |
1 deliver, On | Remove outgoing X-Powered-By for every response. |
Does not change a header already stored in the cache object or remove other information leaks. |
Browser-cache static assets (browser) |
1 deliver, On | Known CSS/JS/image/font extensions, status 200 -> Cache-Control: public, max-age=2592000 (30 days). |
This also changes outgoing headers on BYPASS. Use only for genuinely public static resources. |
No browser cache for HTML/admin (nobrowser) |
1 deliver, On | Any of: Content-Type starts text/html, path starts /admin or path starts /account -> Cache-Control: no-store. |
Only browser cache is affected. Add response no_store or a request pass rule to prevent shared-cache reuse. |
Default security headers (security) |
1 deliver, On | If absent, set X-Content-Type-Options: nosniff and Referrer-Policy: strict-origin-when-cross-origin. |
Does not overwrite existing origin values. Review security policy with the application. |
Staging noindex (stagingnoindex) |
1 deliver, Off | If absent, set X-Robots-Tag: noindex, nofollow on all responses. |
Preventing search indexing is not access control; enable only on staging/private search surfaces after review. |
Frame protection (frameguard) |
1 deliver, Off | If absent, set X-Frame-Options: SAMEORIGIN on all responses. |
May break legitimate embedding or iframe flows; adapt to the site's CSP and embedding requirements. |
7. Other / broad API protection (1 scenario)
| Template (internal key) | Rules / default | Behavior | Limitations |
|---|---|---|---|
API: bypass cache (api) |
1 request, On | Path starts /api/ -> pass. |
Covers both private and public API endpoints. It does not send browser no-store; for public JSON caching remove or narrow this broad pass guard first. |
pass, cookie_pass and static assets
Templates whose only trigger is a cookie insert cookie_pass. For pages it is identical to pass. When Ignore request cookies for static files is on, RustProxy can still cache a public CSS/JS/image/font/... for a logged-in browser, provided no explicit pass (path, method, Authorization, preview, ...) matches the same request and the backend reply is explicitly public. An explicit pass is never relaxed. Rules added from an older version keep pass; the editor offers Convert to Cookie guard for Cookie-only pass rules. Details: decision precedence.
Rule-order pitfalls
passtakes precedence over later request edits: if Any Cookie or CDN BYPASS remaining cookies runs first, a later parent-name cleanup rule never gets a chance to remove irrelevant cookies. This is the typical reason a browser showsX-Cache: BYPASSwithX-Cache-Reason: cache_rule(explicit pass) orcache_rule_cookie(Cookie guard) while a cookie-freecurlgets HIT. Public static assets are no longer affected when the guard is acookie_pass.- A
passafter selective cleanup still sees app sessions:parent_analytics=1; app_session=abcmust becomeapp_session=abc, and the remaining-cookie guard must BYPASS. Never forcelookupto override this. - Global vs Vhost scope matters: matching Vhost rules run before applicable global rules. Ordering controls in one list do not reorder the other list. A terminal request action stops further normal request-stage evaluation; response and deliver stages are separate.
- A broad API guard can defeat public API TTL: request
passon/api/makes a response-stage public JSON TTL irrelevant. Narrow the prefix or use a dedicated public route when desired. - Browser
Cache-Controlis not proxy cache policy: a deliver-onlyno-storeorpublicheader can differ from RustProxy's internal HIT/MISS decision. Protect user-specific content in request/response stages and at the origin. Varymatters: a response withVary: CookieorVary: Accept-Encodingcan legitimately produce separate variants. A browser refresh can sendCache-Control: no-cacheormax-age=0; inspect the original request headers before concluding the cache is broken.
Verification matrix
Use the panel's Test a request first, then verify with repeated real GET requests. Expected results below assume the relevant templates are enabled and ordered as described:
| Request | Expected behavior |
|---|---|
Anonymous GET /catalog |
Normal cache eligibility; first GET can be MISS, next can be HIT. |
GET /catalog with only a verified parent cookie |
Exact name removed; lookup may proceed. |
Same URL with parent_analytics=1; app_session=abc |
Parent cookie removed, session retained -> later BYPASS. |
| Cookie header containing only listed CDN technical cookies | CDN template may remove the entire technical-only header; lookup may proceed. |
| Mixed CDN technical cookie and session | CDN filter does not strip the mixed header -> BYPASS. |
GET /account/orders |
Private-path rule -> BYPASS, backend no-store, browser private, no-store. |
GET /api/private/me |
Private API rule -> BYPASS and no-store. |
GET /?preview=1 |
Preview rule -> BYPASS. |
GET /graphql |
GraphQL rule -> BYPASS. |
POST /checkout |
Non-GET/HEAD or checkout rule -> BYPASS. |
Anonymous GET /api/public/items with public 200 JSON |
Potential TTL 60 s only if public JSON was enabled and no broader /api/ pass rule matched. |
Example HTTP test (use the same URL and GET method repeatedly):
URL="https://example.com/catalog"
for i in 1 2 3; do
curl -sS -o /dev/null -D - "$URL" \
| grep -Ei '^(HTTP/|x-cache:|x-cache-reason:|age:|cache-status:)'
done
# Separate expected BYPASS test for an app session cookie:
curl -sS -o /dev/null -D - \
-H 'Cookie: app_session=example' "$URL" \
| grep -Ei '^(x-cache:|x-cache-reason:|cache-status:)'
In case of unexpected results, compare the browser's request Cookie, Authorization, Cache-Control, exact URL, method and Accept-Encoding against curl. Use the tester's matched-rule names; check Vhost vs global scope and the placement of any terminal pass. Check the backend's Cache-Control, Set-Cookie, status and Vary before changing storage rules.
See also Cache, VCL support matrix, VCL traffic cookbook and Security.