Created
November 26, 2014 17:02
-
-
Save eiriksm/2580408fc7b980e65c15 to your computer and use it in GitHub Desktop.
outtakes.vcl
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sub vcl_recv { | |
# ... some other stuff and logic. | |
# This is so special I keep it in a separate if block. | |
if (req.http.host == "orkjern.com") { | |
# These first lines are based on lullabot's setup. Google it. | |
set req.http.Cookie = ";" + req.http.Cookie; | |
set req.http.Cookie = regsuball(req.http.Cookie, "; +", ";"); | |
# This cookie gets set from javascript. | |
if (req.http.Cookie ~ "ORKJERN_THEME_CACHE") { | |
set req.http.Cookie = ";" + req.http.Cookie; | |
set req.http.Cookie = regsuball(req.http.Cookie, "; +", ";"); | |
set req.http.Cookie = regsuball(req.http.Cookie, ";(ORKJERN_THEME_CACHE=[0-9]*)", " \1="); | |
set req.http.Cookie = regsuball(req.http.Cookie, ";[^ ][^;]*", ""); | |
set req.http.Cookie = regsuball(req.http.Cookie, "^[; ]+|[; ]+$", ""); | |
# Now all of the visitors with the theme cache key will get the same | |
# URL (used as hash for caches). Something like xxx.com/node/1?has_cache=true&cookie=ORKJERN_THEME_CACHE123456 | |
set req.url = req.url + "?has_cache=true&cookie=" + req.http.Cookie; | |
} | |
else { | |
# All visitors without the theme cache hook will also get the same hash. | |
set req.url = req.url + "?has_no_cache=true&cookie=" + req.http.Cookie; | |
} | |
# No-one gets to use cookies on the site, resulting in no-one being able to log in. | |
unset req.http.Cookie; | |
# ... and so on with other logic. | |
} | |
} | |
# Also this: | |
sub vcl_deliver { | |
# Useful for debugging: | |
set resp.http.X-URL = req.url; | |
## ... and then some other things. | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment