Last active
March 21, 2017 15:49
-
-
Save razvanphp/8afb8dc5fa7219465e2af794b106e3f8 to your computer and use it in GitHub Desktop.
varnish strip backend 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_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