Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Symfony2 response - Clear cache headers on back button

I have an issue with clearing my cache when back button is pressed.

My header information is saying i'ts loaded from cache:

Status Code:200 OK (from cache)

My response is set to:

$response = new Response;
$response->expire();
$response->headers->addCacheControlDirective('must-revalidate', true);
$response->headers->addCacheControlDirective('allow_reload', true);

What am I doing wrong? None of the documentation methods seem to work...

like image 545
rat4m3n Avatar asked Mar 30 '13 11:03

rat4m3n


1 Answers

Taking advice from this article and setting listed Cache-Control directives worked for me - by pressing back button request to the server was always sent.

$response->headers->addCacheControlDirective('no-cache', true);
$response->headers->addCacheControlDirective('max-age', 0);
$response->headers->addCacheControlDirective('must-revalidate', true);
$response->headers->addCacheControlDirective('no-store', true);
like image 139
gatisl Avatar answered Oct 19 '22 12:10

gatisl