Skip to content

Instantly share code, notes, and snippets.

@ksheurs
Created January 16, 2014 17:07
Show Gist options
  • Select an option

  • Save ksheurs/8458939 to your computer and use it in GitHub Desktop.

Select an option

Save ksheurs/8458939 to your computer and use it in GitHub Desktop.
vcl_fetch
sub vcl_fetch {
if ((beresp.status == 500 || beresp.status == 503) && req.restarts < 1 && (req.request == "GET" || req.request == "HEAD")) {
restart;
}
if (req.restarts > 0) {
set beresp.http.Fastly-Restarts = req.restarts;
}
if (beresp.http.Set-Cookie) {
set req.http.Fastly-Cachetype = "SETCOOKIE";
return (pass);
}
if (beresp.http.Cache-Control ~ "private") {
set req.http.Fastly-Cachetype = "PRIVATE";
return (pass);
}
if (beresp.status == 500 || beresp.status == 503) {
set req.http.Fastly-Cachetype = "ERROR";
set beresp.ttl = 1s;
set beresp.grace = 5s;
return (deliver);
}
unset beresp.http.Server;
unset beresp.http.x-amz-id-2;
unset beresp.http.x-amz-request-id;
set beresp.http.Server = "Varnish";
set beresp.ttl = 31557600s;
return(deliver);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment