点击浏览器后退按钮,重新刷新页面,而不是从缓存中获取页面,PHP的解决方案

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/sdutphp/article/details/84638981

背景:在A页面中提交表单后,跳转至结果页B,在B页单击浏览器的后退按钮,回到A页面时,希望保留上次A页面的查询条件。

框架:ThinkPHP 3.2.3

核心代码:

C('HTTP_CACHE_CONTROL', 'private, max-age=0, no-store, no-cache, must-revalidate');
header("Expires: Thu, 04 Jan 2018 08:00:00 GMT");
header('Cache-Control: post-check=0, pre-check=0', false);
header('Pragma: no-cache');

如果未使用PHP框架,应修改为:

header("Expires: Thu, 04 Jan 2018 08:00:00 GMT");
header('Cache-Control: private, max-age=0, no-store, no-cache, must-revalidate');
header('Cache-Control: post-check=0, pre-check=0', false);
header('Pragma: no-cache');

猜你喜欢

转载自blog.csdn.net/sdutphp/article/details/84638981