Created
October 12, 2017 06:16
-
-
Save section-io-gists/bad6cfc58a4db2cb461c3cc53a565cc3 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 (req.method != "GET" && req.method != "HEAD" && req.method != "PURGE") { | |
return (pass); | |
} | |
// Rest of vcl_recv code | |
return(hash); | |
} | |
sub vcl_backend_response { | |
if (bereq.method != "GET" && bereq.method != "HEAD" && bereq.method != "PURGE") { | |
set beresp.uncacheable = true; | |
set beresp.ttl = 120s; | |
return (deliver); | |
} | |
if (beresp.http.Content-Type ~ "text/html" && beresp.status < 400) { | |
if (bereq.http.Cookie !~ "ASP.NET_SessionId" && bereq.url !~ "(/[Cc]art|/[Cc]heckout|/[Aa]dmin|/[Ll]ogin|/[Aa]ccount)") { | |
unset beresp.http.Set-Cookie; | |
set beresp.ttl = 6h; | |
set beresp.grace = 12h; | |
} else { | |
set beresp.uncacheable = true; | |
set beresp.ttl = 120s; | |
} | |
return (deliver); | |
} | |
} | |
sub vcl_hash { | |
if (req.http.Cookie !~ "ASP.NET_SessionId" && req.url !~ "(/[Cc]art|/[Cc]heckout|/[Aa]dmin|/[Ll]ogin|/[Aa]ccount)") { | |
hash_data("no_unique_cookie"); | |
} else { | |
hash_data("has_unique_cookie"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment