Skip to content
This repository has been archived by the owner on Sep 5, 2023. It is now read-only.

Commit

Permalink
Add some stuff not reproduced by macros
Browse files Browse the repository at this point in the history
  • Loading branch information
dcarley authored and alexmuller committed Mar 22, 2016
1 parent ea8ef3b commit 03cb1fc
Showing 1 changed file with 49 additions and 1 deletion.
50 changes: 49 additions & 1 deletion govuk.vcl
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,52 @@ sub vcl_recv {
# << custom recv

#FASTLY recv

# >> not reproduced by macro
if (req.request != "HEAD" && req.request != "GET" && req.request != "PURGE") {
return(pass);
}

return(lookup);
# << not reproduced by macro
}

sub vcl_fetch {
#FASTLY fetch

# >> not reproduced by macro
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);
}

if (beresp.http.Expires || beresp.http.Surrogate-Control ~ "max-age" || beresp.http.Cache-Control ~"(s-maxage|max-age)") {
# keep the ttl here
} else {
# apply the default ttl
set beresp.ttl = 3600s;
}
# << not reproduced by macro
}

sub vcl_hit {
Expand Down Expand Up @@ -85,5 +127,11 @@ sub vcl_pass {
}

sub vcl_hash {
#FASTLY hash
# >> not reproduced by macro
# `FASTLY hash` only appends `#####GENERATION#####`
set req.hash += req.url;
set req.hash += req.http.host;
set req.hash += "#####GENERATION#####";
return (hash);
# << not reproduced by macro
}

0 comments on commit 03cb1fc

Please sign in to comment.