File tree 2 files changed +13
-0
lines changed
src/Symfony/Component/HttpFoundation
2 files changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -310,6 +310,11 @@ public function prepare(Request $request)
310
310
$ this ->headers ->set ('expires ' , -1 );
311
311
}
312
312
313
+ // Don't send default cache header for 301 redirects
314
+ if (301 == $ this ->statusCode && !array_key_exists ('cache-control ' , $ this ->headers )) {
315
+ $ this ->headers ->remove ('cache-control ' );
316
+ }
317
+
313
318
$ this ->ensureIEOverSSLCompatibility ($ request );
314
319
315
320
return $ this ;
Original file line number Diff line number Diff line change @@ -544,6 +544,14 @@ public function testPrepareRemovesContentLength()
544
544
$ this ->assertFalse ($ response ->headers ->has ('Content-Length ' ));
545
545
}
546
546
547
+ public function testPrepareRemovesDefaultCacheHeaderForPermanentRedirect ()
548
+ {
549
+ $ response = new Response ('foo ' , 301 );
550
+ $ request = Request::create ('/ ' );
551
+ $ response ->prepare ($ request );
552
+ $ this ->assertFalse ($ response ->headers ->hasCacheControlDirective ('no-cache ' ));
553
+ }
554
+
547
555
public function testPrepareSetsPragmaOnHttp10Only ()
548
556
{
549
557
$ request = Request::create ('/ ' , 'GET ' );
You can’t perform that action at this time.
0 commit comments