PHP Redirect that force refresh (CTRL+F5)

只谈情不闲聊 提交于 2019-12-02 00:00:49

问题


I have a page with an editable table. I need users to be able to edit this and then submit their changes. Everything works well until I redirect them to the same page with new content (relevant to their changes). However, they see the old content.

If I press ctrl+f5 on the browser, they content gets updated. I was wondering if there is a way to force this. This is my php code which does not help force refreshing:

header('Cache-Control: no-cache, no-store, max-age=0, must-revalidate');
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); // Date in the past
header('Pragma: no-cache');
header( 'Location: http://www.bamozir.com/en/mtl-en/recent/general-info/cost#edit' );

Eugen Rieck Solution works perfect for firefox, chrome, and safari. But not on IE and Opera. Any idea how to fix this?


回答1:


What ALLWAYS works: Assuming your URL is http://my.server/my/page?a=b&c=d you redirect to http://my.server/my/page?a=b&c=d&nocache=1234567890 with 1234567890 being a large random number




回答2:


You must set the cache control and expiration on the page which you wish to force-refresh on. By setting that before the redirect, you're telling the browser to not cache the page you're redirecting from.




回答3:


Use this header to use refresh:

Refresh: 0;url=http://www.bamozir.com/en/mtl-en/recent/general-info/cost#edit

See more on that topic here: 'Refresh' HTTP header



来源:https://stackoverflow.com/questions/8577762/php-redirect-that-force-refresh-ctrlf5

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