Skip to content

Commit

Permalink
Put 50x abandon above catchall 2min cache
Browse files Browse the repository at this point in the history
In my testing, my errors were caught/TTL set before the abandon see mattiasgeniar#24
  • Loading branch information
LukeHandle authored Sep 17, 2017
1 parent 8f10a29 commit 3769f8a
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions default.vcl
Original file line number Diff line number Diff line change
Expand Up @@ -330,18 +330,18 @@ sub vcl_backend_response {
set beresp.http.Location = regsub(beresp.http.Location, ":[0-9]+", "");
}

# Don't cache 50x responses
if (beresp.status == 500 || beresp.status == 502 || beresp.status == 503 || beresp.status == 504) {
return (abandon);
}

# Set 2min cache if unset for static files
if (beresp.ttl <= 0s || beresp.http.Set-Cookie || beresp.http.Vary == "*") {
set beresp.ttl = 120s; # Important, you shouldn't rely on this, SET YOUR HEADERS in the backend
set beresp.uncacheable = true;
return (deliver);
}

# Don't cache 50x responses
if (beresp.status == 500 || beresp.status == 502 || beresp.status == 503 || beresp.status == 504) {
return (abandon);
}

# Allow stale content, in case the backend goes down.
# make Varnish keep all objects for 6 hours beyond their TTL
set beresp.grace = 6h;
Expand Down

0 comments on commit 3769f8a

Please sign in to comment.