Last active
August 29, 2015 14:01
-
-
Save simonwistow/2fa534508a3f6ae72508 to your computer and use it in GitHub Desktop.
Tracking cookies
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 { | |
if (req.http.Cookie ~ "mycookie=") { | |
# The request does have a tracking cookie so store it temporarily | |
set req.http.Tmp-Set-Cookie = req.http.Cookie; | |
unset req.http.Cookie; | |
} else { | |
# The request doesn't have a tracking cookie so force a miss | |
set req.hash_always_miss = true; | |
} | |
#FASTLY recv | |
} | |
sub vcl_fetch { | |
# The response has a Set-Cookie ... | |
if (beresp.http.Set-Cookie) { | |
# ... so store it temporarily | |
set req.http.Tmp-Set-Cookie = beresp.http.Set-Cookie; | |
# ... and then unset it | |
unset beresp.http.Set-Cookie; | |
} | |
#FASTLY fetch | |
} | |
sub vcl_deliver { | |
# Send the Cookie header again if we have it | |
if (req.http.Tmp-Set-Cookie) { | |
set resp.http.Set-Cookie = req.http.Tmp-Set-Cookie; | |
} | |
#FASTLY deliver | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I can't believe Github doesn't have a VCL type for gists, calling this a perl file seems super-icky