Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@razvanphp
Last active March 21, 2017 15:49
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 razvanphp/8afb8dc5fa7219465e2af794b106e3f8 to your computer and use it in GitHub Desktop.
Save razvanphp/8afb8dc5fa7219465e2af794b106e3f8 to your computer and use it in GitHub Desktop.
varnish strip backend cookies
sub vcl_backend_response {
# Happens after we have read the response headers from the backend.
#
# Here you clean the response headers, removing silly Set-Cookie
# headers and other mistakes your backend does.
if (bereq.url ~ "^/$" ||
bereq.url ~ "^/(frauen|maenner|kinder|outlet|marke)(/.+)?" ||
bereq.url ~ "^/api/(seen2bought/|similarProduct/|product\?)" ||
bereq.url ~ "\.(css|js)\?.*" ||
bereq.url ~ "\.(png|gif|jpg|ico|js|css|xml|pdf|woff|ttf)$"
){
# time-to-live 30 minutes
set beresp.ttl = 1800s;
unset beresp.http.set-cookie;
unset beresp.http.Pragma;
unset beresp.http.Expires;
}
# dont cache redirects and errors
if (beresp.status >= 300) {
set beresp.uncacheable = true;
set beresp.ttl = 30s;
return (deliver);
}
# …
return (deliver);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment