Last active
April 13, 2019 20:20
-
-
Save joseluisq/481e863ec30835a3bd1c to your computer and use it in GitHub Desktop.
Varnish Cache v3 configuration for subdomains
This file contains 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
# Customizing Varnish Cache for subdomains | |
backend default { | |
.host = "127.0.0.1"; | |
.port = "8080"; | |
} | |
sub vcl_recv { | |
# If exists any trouble, disable the cookie | |
if (!req.backend.healthy) { | |
unset req.http.Cookie; | |
} | |
# No-Cache: "nocache.domain.com" | |
if (req.http.host ~ "nocache\.domain\.com") { | |
return(pass); | |
} | |
# Cache: "domain.com", "cache.domain.com" and "cdn.domain.com" | |
if (req.http.host ~ "(^((cache|cdn)\.)?domain\.com)$") { | |
if (req.url ~ "\.(png|gif|jpg|swf|css|js|svg|eot|ttf|otf|ttc|webm|woff|woff2|mp3|mp4|ogg|flv|ogv|m4v|oga|pdf|csv|xls|xlsx|doc|docx|ppt|pptx|txt)$") { | |
unset req.http.Cookie; | |
return(lookup); | |
} | |
} | |
} | |
sub vcl_fetch { | |
# Unset cookie: "domain.com", "cache.domain.com" and "cdn.domain.com" | |
if (req.http.host ~ "(^((cache|cdn)\.)?domain\.com)$") { | |
if (req.url ~ "\.(png|gif|jpg|swf|css|js|svg|eot|ttf|otf|ttc|webm|woff|woff2|mp3|mp4|ogg|flv|ogv|m4v|oga|pdf|csv|xls|xlsx|doc|docx|ppt|pptx|txt)$") { | |
unset beresp.http.set-cookie; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment