Skip to content

Commit

Permalink
Add Surrogate-Control header to stop fastly caching by accident
Browse files Browse the repository at this point in the history
  • Loading branch information
ranguard committed Nov 22, 2013
1 parent 6db8046 commit 2a98089
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions lib/MetaCPAN/Web/Controller/Root.pm
Expand Up @@ -81,6 +81,16 @@ sub end : ActionClass('RenderView') {
$c->stash->{api} = $c->config->{api};
$c->stash->{api_secure} = $c->config->{api_secure} || $c->config->{api};
$c->res->header( Vary => 'Cookie' );

unless(
# Already have something set for fastly
$c->res->header('Surrogate-Control') ||
# We'll use Last-Modified for now
$c->res->header('Last-Modified')
) {
# Make sure fastly doesn't cache anything by accident
$c->res->header('Surrogate-Control' => 0);
}
}

=head1 AUTHOR
Expand Down

0 comments on commit 2a98089

Please sign in to comment.