This commit is contained in:
Mateusz Gruszczyński committed 2026-11-20 23:14:19 +01:00
1 parent d455028de3
commit 5b2eaaff61
36 files changed
+2544 -102

No files matched your search

+11 -7
View File
@@ -1,6 +1,6 @@
# Cache rule template library: all 42 scenarios
**Applies to RustProxy 0.39.1.** 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.
**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](VCL.md); for copyable VCL examples, see the [traffic cookbook](VCL_TRAFFIC_COOKBOOK.md).
@@ -20,8 +20,8 @@ A template is **On** if its generated rule(s) are enabled when inserted; **Off**
|---|---|---|---|
| **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 -> `pass`. | 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` -> `pass`. | Not an exhaustive session list. Add app-specific names or use **Any Cookie** as a fallback. |
| **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. |
@@ -38,7 +38,7 @@ These templates are **cache protections, not authentication or authorization**.
## 2. CMS and framework sessions (7 scenarios)
All seven insert a **request-stage `pass` rule, enabled by default**. They **retain** cookies and forward them to the backend; none rewrites a session cookie.
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 |
|---|---|---|
@@ -56,7 +56,7 @@ A framework template recognizes only the listed paths or cookie names. Where a s
| 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 `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. |
| **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:**
@@ -74,7 +74,7 @@ For copyable VCL syntax, see [parent-domain cookie removal](VCL_TRAFFIC_COOKBOOK
## 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.1. They do not necessarily change `Cache-Control` seen by a browser.
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... |
|---|---|---|---|
@@ -116,9 +116,13 @@ These run at the **deliver** stage. Unless accompanied by request/response rules
|---|---|---|---|
| **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](CACHE.md#cache-decision-precedence-explicit-pass-and-public-static-assets).
## Rule-order pitfalls
- **`pass` takes 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 shows `X-Cache: BYPASS` with `X-Cache-Reason: cache_rule` while a cookie-free `curl` gets HIT.
- **`pass` takes 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 shows `X-Cache: BYPASS` with `X-Cache-Reason: cache_rule` (explicit pass) or `cache_rule_cookie` (Cookie guard) while a cookie-free `curl` gets HIT. Public static assets are no longer affected when the guard is a `cookie_pass`.
- **A `pass` after selective cleanup still sees app sessions:** `parent_analytics=1; app_session=abc` must become `app_session=abc`, and the remaining-cookie guard must BYPASS. Never force `lookup` to 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 `pass` on `/api/` makes a response-stage public JSON TTL irrelevant. Narrow the prefix or use a dedicated public route when desired.