Skip to content

Commit

Permalink
Do not blow the cache on 50x responses, fixes issue mattiasgeniar#6
Browse files Browse the repository at this point in the history
  • Loading branch information
mattiasgeniar committed Mar 27, 2016
1 parent ed0e1f5 commit 3e59d24
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion default.vcl
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ sub vcl_backend_response {
if (bereq.url ~ "^[^?]*\.(7z|avi|bz2|flac|flv|gz|mka|mkv|mov|mp3|mp4|mpeg|mpg|ogg|ogm|opus|rar|tar|tgz|tbz|txz|wav|webm|xz|zip)(\?.*)?$") {
unset beresp.http.set-cookie;
set beresp.do_stream = true; # Check memory usage it'll grow in fetch_chunksize blocks (128k by default) if the backend doesn't send a Content-Length header, so only enable it for big objects
set beresp.do_gzip = false; # Don't try to compress it for storage
set beresp.do_gzip = false; # Don't try to compress it for storage
}

# Sometimes, a 301 or 302 redirect formed via Apache's mod_rewrite can mess with the HTTP port that is being passed along.
Expand All @@ -334,6 +334,11 @@ sub vcl_backend_response {
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 3e59d24

Please sign in to comment.