/
recv.vcl
49 lines (44 loc) · 2.12 KB
/
recv.vcl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
if (fastly.ff.visits_this_service > 0) {
# Needed for proper handling of stale while revalidated when shielding is involved
set req.max_stale_while_revalidate = 0s;
}
## always cache these images & static assets
if (req.request == "GET" && req.url.ext ~ "(?i)(css|js|gif|jpg|jpeg|bmp|png|ico|img|tga|webp|wmf)") {
remove req.http.cookie;
} else if (req.request == "GET" && req.url.path ~ "(xmlrpc\.php|wlmanifest\.xml)") {
remove req.http.cookie;
}
### do not cache these files:
## never cache the admin pages, or the server-status page
if (req.request == "GET" && (req.url.path ~ "(wp-admin|bb-admin|server-status)")) {
set req.http.X-Pass = "1";
} else if (req.http.X-Requested-With == "XMLHttpRequest" && req.url !~ "recent_reviews") {
# Do not cache ajax requests except for recent reviews
set req.http.X-Pass = "1";
} else if (req.url.qs ~ "nocache" ||
req.url.path ~ "(control\.php|wp-comments-post\.php|wp-login\.php|bb-login\.php|bb-reset-password\.php|register\.php)") {
set req.http.X-Pass = "1";
# Woocommerce sets cart as cacheable. Need to make sure we never cache it
} else if (req.url.path ~ "/cart/?$" ) {
set req.http.X-Pass = "1";
}
# Remove wordpress_test_cookie except on non-cacheable paths
if (!req.http.X-Pass && req.http.Cookie:wordpress_test_cookie) {
remove req.http.Cookie:wordpress_test_cookie;
}
if ( req.http.Cookie ) {
### do not cache authenticated sessions
if (req.http.Cookie ~ "(wordpress_|PHPSESSID)") {
set req.http.X-Pass = "1";
} else if (!req.http.X-Pass) {
# Cleans up cookies by removing everything except vendor_region, PHPSESSID and themetype2
set req.http.Cookie = ";" req.http.Cookie;
set req.http.Cookie = regsuball(req.http.Cookie, "; +", ";");
set req.http.Cookie = regsuball(req.http.Cookie, ";(vendor_region|PHPSESSID|themetype2|.*woocommerce.*)=", "; \1=");
set req.http.Cookie = regsuball(req.http.Cookie, ";[^ ][^;]*", "");
set req.http.Cookie = regsuball(req.http.Cookie, "^[; ]+|[; ]+$", "");
if (req.http.Cookie == "") {
remove req.http.Cookie;
}
}
}