Skip to content

Commit 9c2f358

Browse files
author
Evan Kaufman
committed
Simplified cookie logic in receive/wordpress.vcl
* The existing wp cookie check was *starting with* `wp-` or `wprdpress_`, but would not match a 2nd or higher position wp cookie * The second url check for `wp-(login|admin)` was no longer necessary, so removing all cookies past that point is more efficient
1 parent 3fd9d0c commit 9c2f358

1 file changed

Lines changed: 5 additions & 10 deletions

File tree

  • provisioning/roles/varnish/files/etc-varnish/conf.d/receive

provisioning/roles/varnish/files/etc-varnish/conf.d/receive/wordpress.vcl

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,14 @@ if (req.http.Host ~ "^local\." || (req.url ~ "wp-(login|admin)")) {
33
return (pass);
44
}
55

6-
if (req.http.Cookie ~ "^wp-" || req.http.Cookie ~ "^wordpress_") {
6+
# Pass all requests containing a wp- or wordpress_ cookie
7+
# (meaning NO caching for logged in users)
8+
if (req.http.Cookie ~ "^([^;]+;\s*)*?(wp-|wordpress_)") {
79
return (pass);
810
}
911

10-
# Drop any cookies sent to Wordpress.
11-
if (!(req.url ~ "wp-(login|admin)")) {
12-
unset req.http.Cookie;
13-
}
14-
15-
# Anything else left?
16-
if (!req.http.Cookie) {
17-
unset req.http.Cookie;
18-
}
12+
# Drop *all* cookies sent to Wordpress, if we've gotten this far
13+
unset req.http.Cookie;
1914

2015
# Try a cache-lookup
2116
return (lookup);

0 commit comments

Comments
 (0)