Skip to content

Instantly share code, notes, and snippets.

@section-io-gists
Created October 12, 2017 06:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save section-io-gists/441758d7d268c3c96ddb080cd1c335c1 to your computer and use it in GitHub Desktop.
Save section-io-gists/441758d7d268c3c96ddb080cd1c335c1 to your computer and use it in GitHub Desktop.
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