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

Commit

Permalink
Don't cache CC no-store/no-cache
Browse files Browse the repository at this point in the history
Don't cache responses with these headers. In order to match:

- CloudFlare's default behaviour
- cdn-acceptance-tests mocks:
  alphagov/cdn-acceptance-tests@47585a2
- cache-N.router config:
  https://github.gds/gds/puppet/commit/8c5c1876b3860fad386357bfdc0b94d12c03c878

This should come next to the handling of CC private because we want to do
this after 5xx handling and return() before doing anything. I've opened and
closed the comments to indicate that this isn't part of the macro that we've
copied.

Run against the acceptance test service. Two errors are pre-existing:

    dcarley@ci-slave-4:~/cdn-acceptance-tests$ go test -edgeHost fastly.cdn-acceptance-test.alphagov.co.uk -skipVerifyTLS -skipFailover
    2014/08/07 14:17:26 Confirming that CDN is healthy
    2014/08/07 14:17:26 Started server on port 8080
    2014/08/07 14:17:26 Checking health of origin...
    2014/08/07 14:17:27 origin is up!
    --- FAIL: TestNoCacheHeaderCookie (0.08 seconds)
            helpers.go:360: Incorrect response body. Expected "second response", got "first response"
            helpers.go:360: Incorrect response body. Expected "third response", got "first response"
    --- FAIL: TestNoCacheHeaderCacheControlMaxAge0 (0.02 seconds)
            helpers.go:360: Incorrect response body. Expected "second response", got "first response"
            helpers.go:360: Incorrect response body. Expected "third response", got "first response"
    2014/08/07 14:17:54 Started server on port 33265
    2014/08/07 14:17:54 Started server on port 33265
    2014/08/07 14:17:54 Started server on port 49001
    2014/08/07 14:17:55 Started server on port 46997
    2014/08/07 14:17:55 Started server on port 39178
    FAIL
    exit status 1
    FAIL    _/home/dcarley/cdn-acceptance-tests     28.134s
  • Loading branch information
dcarley authored and alexmuller committed Mar 22, 2016
1 parent f704e26 commit fa56132
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions vcl_templates/www.vcl.erb
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,14 @@ sub vcl_fetch {
return (pass);
}

# << not reproduced by macro
# >> custom
if (beresp.http.Cache-Control ~ "no-(store|cache)") {
return (pass);
}
# << custom
# >> not reproduced by macro

if (beresp.status >= 500 && beresp.status <= 599) {
set req.http.Fastly-Cachetype = "ERROR";
set beresp.ttl = 1s;
Expand Down

0 comments on commit fa56132

Please sign in to comment.