Skip to content

Commit f972e5f

Browse files
committed
Skip cache headers on error responses
post_process() was setting Cache-Control: max-age=43200 on all responses including 4xx/5xx errors, causing error pages to be cached for 12 hours. Now checks response status and uses no-cache headers when status >= 400.
1 parent e4e70ec commit f972e5f

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

lib/CN/Control.pm

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,10 @@ sub init {
7272
sub post_process {
7373
my $self = shift;
7474

75-
my $req = $self->request;
75+
my $req = $self->request;
76+
my $status = $req->response->status || 200;
7677

77-
if ($self->no_cache) {
78+
if ($self->no_cache || $status >= 400) {
7879
$req->header_out('Cache-Control', 'no-cache,max-age=0,private');
7980
$req->header_out('Pragma', 'no-cache');
8081
}

0 commit comments

Comments
 (0)