v0.39.0
This commit is contained in:
1 parent
5e43752041
commit
15425fb803
34 files changed
+1423
-89
No files matched your search
@@ -0,0 +1,9 @@
|
||||
// ADVANCED / HIGH RISK. Only for a verified identical public representation.
|
||||
// Removes Set-Cookie before storage and before forwarding the origin response.
|
||||
// NEVER apply to login, accounts, cart, personalized JSON or CSRF flows.
|
||||
sub vcl_backend_response {
|
||||
if (bereq.url ~ "^/public/banner[.]svg([?]|$)" && beresp.status == 200 && beresp.http.Cache-Control ~ "(^|,) *public(,|$)") {
|
||||
unset beresp.http.Set-Cookie;
|
||||
set beresp.ttl = 1h;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
// Optional template: only shared/public content independent of these cookies.
|
||||
// Cloudflare: __cf_bm, cf_clearance, _cfuvid, __cfruid, __cfseq
|
||||
// Akamai: _abck, ak_bmsc, bm_sz, bm_sv
|
||||
// Security cookies can be needed for bot challenges; review before enabling.
|
||||
sub vcl_recv {
|
||||
if (req.method != "GET" && req.method != "HEAD") {
|
||||
return(pass);
|
||||
}
|
||||
if (req.url ~ "^/(admin|api|auth|login|logout|panel|konto|dashboard)(/|[?]|$)") {
|
||||
return(pass);
|
||||
}
|
||||
if (req.http.Authorization) {
|
||||
return(pass);
|
||||
}
|
||||
// Match the complete Cookie header, not one cookie within it.
|
||||
if (req.http.Cookie ~ "^(?:__cf_bm|cf_clearance|_cfuvid|__cfruid|__cfseq|_abck|ak_bmsc|bm_sz|bm_sv)=[^;]*(?:;[ \t]*(?:__cf_bm|cf_clearance|_cfuvid|__cfruid|__cfseq|_abck|ak_bmsc|bm_sz|bm_sv)=[^;]*)*$") {
|
||||
unset req.http.Cookie;
|
||||
}
|
||||
if (req.http.Cookie) {
|
||||
return(pass);
|
||||
}
|
||||
return(hash);
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
// Controlled, PUBLIC A/B variants: client sends X-Experiment: A or B.
|
||||
// Origin must also return Vary: X-Experiment, preserve other Vary fields,
|
||||
// and never associate this header with credentials or private data.
|
||||
sub vcl_recv {
|
||||
if (req.method != "GET" && req.method != "HEAD") {
|
||||
return(pass);
|
||||
}
|
||||
if (req.http.Authorization || req.http.Cookie) {
|
||||
return(pass);
|
||||
}
|
||||
if (req.url ~ "^/experiment(/|[?]|$)") {
|
||||
if (req.http.X-Experiment ~ "^(A|B)$") {
|
||||
return(hash);
|
||||
}
|
||||
return(pass);
|
||||
}
|
||||
return(pass);
|
||||
}
|
||||
|
||||
sub vcl_hash {
|
||||
hash_data(req.http.X-Experiment);
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
// Request header sanitation (safe, ordinary representation headers only).
|
||||
// Deliver mutations do not change the object stored in cache.
|
||||
sub vcl_recv {
|
||||
if (req.url ~ "^/catalog(/|[?]|$)") {
|
||||
unset req.http.X-Marketing-Source;
|
||||
set req.http.X-Edge-Policy = "catalog-v1";
|
||||
}
|
||||
}
|
||||
|
||||
sub vcl_deliver {
|
||||
if (req.url ~ "^/catalog(/|[?]|$)") {
|
||||
unset resp.http.X-Debug;
|
||||
set resp.http.X-Edge-Policy = "catalog-v1";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
// Origin responsibility: return Vary: Accept-Language (plus any other real
|
||||
// dimensions such as Accept-Encoding), public freshness and no Set-Cookie.
|
||||
// Do not replace the origin Vary list with a single dimension.
|
||||
sub vcl_recv {
|
||||
if (req.method != "GET" && req.method != "HEAD") {
|
||||
return(pass);
|
||||
}
|
||||
if (req.http.Authorization || req.http.Cookie) {
|
||||
return(pass);
|
||||
}
|
||||
if (req.url ~ "^/translations(/|[?]|$)") {
|
||||
return(hash);
|
||||
}
|
||||
return(pass);
|
||||
}
|
||||
|
||||
sub vcl_backend_response {
|
||||
if (bereq.url ~ "^/translations(/|[?]|$)" && beresp.status == 200 && beresp.http.Cache-Control ~ "(^|,) *public(,|$)") {
|
||||
set beresp.ttl = 60s;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
// Defensive exclusions for an existing HTTP reverse-proxy vhost.
|
||||
// Does not opt in to caching for other routes.
|
||||
sub vcl_recv {
|
||||
if (req.method != "GET" && req.method != "HEAD") {
|
||||
return(pass);
|
||||
}
|
||||
if (req.url ~ "^/(admin|api/private|account|auth|login|logout|checkout|cart|dashboard|webhook)(/|[?]|$)") {
|
||||
return(pass);
|
||||
}
|
||||
if (req.http.Authorization) {
|
||||
return(pass);
|
||||
}
|
||||
if (req.http.Cookie) {
|
||||
return(pass);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
// Cache only demonstrably public catalog pages. The origin must supply
|
||||
// Cache-Control: public, max-age=120 and must not vary by user/session.
|
||||
sub vcl_recv {
|
||||
if (req.method != "GET" && req.method != "HEAD") {
|
||||
return(pass);
|
||||
}
|
||||
if (req.http.Authorization || req.http.Cookie) {
|
||||
return(pass);
|
||||
}
|
||||
if (req.url ~ "^/catalog(/|[?]|$)") {
|
||||
return(hash);
|
||||
}
|
||||
return(pass);
|
||||
}
|
||||
|
||||
sub vcl_backend_response {
|
||||
if (bereq.url ~ "^/catalog(/|[?]|$)" && beresp.status == 200 && beresp.http.Cache-Control ~ "(^|,) *public(,|$)") {
|
||||
set beresp.ttl = 120s;
|
||||
set beresp.grace = 20s;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
// GET-only shared caching for /api/public. Other API routes bypass.
|
||||
// The origin must mark genuinely public JSON responses as such.
|
||||
sub vcl_recv {
|
||||
if (req.method != "GET" && req.method != "HEAD") {
|
||||
return(pass);
|
||||
}
|
||||
if (req.http.Authorization || req.http.Cookie) {
|
||||
return(pass);
|
||||
}
|
||||
if (req.url ~ "^/api/public(/|[?]|$)") {
|
||||
return(hash);
|
||||
}
|
||||
return(pass);
|
||||
}
|
||||
|
||||
sub vcl_backend_response {
|
||||
if (bereq.url ~ "^/api/public(/|[?]|$)" && beresp.status == 200 && beresp.http.Content-Type ~ "^application/json" && beresp.http.Cache-Control ~ "(^|,) *public(,|$)") {
|
||||
set beresp.ttl = 15s;
|
||||
set beresp.grace = 5s;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
// Optional: remove ALL request cookies for public, identity-independent
|
||||
// assets under /assets. Origin must never use a session for these assets.
|
||||
// Vary: Cookie removal is NOT accomplished by this VCL. Configure the
|
||||
// native "Ignore Vary: Cookie for public static assets" setting separately.
|
||||
sub vcl_recv {
|
||||
if (req.method != "GET" && req.method != "HEAD") {
|
||||
return(pass);
|
||||
}
|
||||
if (req.url ~ "^/assets/.*[.](css|js|png|jpg|jpeg|svg|woff2)([?]|$)") {
|
||||
if (req.http.Authorization) {
|
||||
return(pass);
|
||||
}
|
||||
unset req.http.Cookie;
|
||||
return(hash);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
// Defense in depth for streaming and transient backend responses.
|
||||
// Does not implement retries, synthetic error handling or stale-if-error.
|
||||
sub vcl_recv {
|
||||
if (req.url ~ "^/(events|stream|webhook)(/|[?]|$)") {
|
||||
return(pass);
|
||||
}
|
||||
}
|
||||
|
||||
sub vcl_backend_response {
|
||||
if (beresp.http.Content-Type ~ "^text/event-stream") {
|
||||
set beresp.uncacheable = true;
|
||||
return(deliver);
|
||||
}
|
||||
if (beresp.status >= 500) {
|
||||
set beresp.uncacheable = true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
// Demonstrates the ONLY recognized req.url regsuball form.
|
||||
// Import WILL WARN: converted to native strip_query with potentially
|
||||
// different URL separator/empty-value normalization. Review and accept
|
||||
// partial import only if the original URL parameters have no origin impact.
|
||||
sub vcl_recv {
|
||||
if (req.url ~ "^/landing([?]|$)") {
|
||||
set req.url = regsuball(req.url, "([?&])(utm_source|utm_medium|gclid)=[^&]*", "\1");
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user