Created
October 12, 2017 06:18
-
-
Save section-io-gists/441758d7d268c3c96ddb080cd1c335c1 to your computer and use it in GitHub Desktop.
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 the request isn't GET|HEAD|PURGE { | |
skip the rest of vcl_recv code | |
} | |
// Rest of vcl_recv code | |
perform a lookup in cache | |
} | |
sub vcl_backend_response { | |
if the request isn't GET|HEAD|PURGE { | |
mark responses as uncacheable (We don’t want to cache requests such as POST) | |
remember the above decision for 120 seconds | |
call the deliver function | |
} | |
if the response from origin is text/html and is not an error { | |
if the request has no session cookie, and isn't personalised URL { | |
remove the Set-Cookie header from the response to the browser | |
set a cache expiry time of 6 hours | |
set a state while re-validate time of 12 hours | |
} else { | |
mark the response as uncacheable | |
remember the above decision for 120 seconds | |
} | |
call the deliver function | |
} | |
} | |
sub vcl_hash { | |
as a precaution, split the cache between in session and anonymous users { | |
hash_data("has_session_cookie"); | |
} else { | |
hash_data("no_session_cookie"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment