Symfony2 response - Clear cache headers on back button

北城余情 提交于 2019-12-22 05:58:41

问题


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...


回答1:


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);


来源:https://stackoverflow.com/questions/15717906/symfony2-response-clear-cache-headers-on-back-button

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!