Skip to content

Instantly share code, notes, and snippets.

@jberkel
Created August 13, 2010 13:10
Show Gist options
  • Select an option

  • Save jberkel/522848 to your computer and use it in GitHub Desktop.

Select an option

Save jberkel/522848 to your computer and use it in GitHub Desktop.
sub vcl_fetch {
# Enable grace period
set beresp.grace = 1h;
# Add X-Cacheable header to track cache miss reasons
if (beresp.http.Set-Cookie) {
set beresp.http.X-Cacheable = "NO:Set-Cookie";
} elseif (beresp.http.Pragma ~ "no-cache") {
set beresp.http.X-Cacheable = "NO:Pragma=no-cache";
} elseif (beresp.http.Pragma ~ "no-store") {
set beresp.http.X-Cacheable = "NO:Pragma=no-store";
} elseif (beresp.http.Cache-Control ~ "no-cache") {
set beresp.http.X-Cacheable = "NO:Cache-Control=no-cache";
} elseif (beresp.http.Cache-Control ~ "max-age=0") {
set beresp.http.X-Cacheable = "NO:Cache-Control=max-age=0";
} elseif (beresp.http.Cache-Control ~ "private") {
set beresp.http.X-Cacheable = "NO:Cache-Control=private";
} elseif (!beresp.cacheable) {
set beresp.http.X-Cacheable = "NO:Not Cacheable";
} else {
set beresp.http.X-Cacheable = "YES";
return(deliver);
}
return(pass);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment