Home > Backend Development > PHP Tutorial > 为什么设置cache-control不起作用

为什么设置cache-control不起作用

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-06 20:25:36
Original
2011 people have browsed it

我用的thinkphp框架 我想在一个页面后退时 也就是点击浏览器的后退按钮时 这个被后退的页面重新加载 而不是读取缓存 我在这个页面对应的控制器方法中添加了 header("Cache-Control: no-cache, must-revalidate"); 但是cache_control不起作用 为啥

回复内容:

我用的thinkphp框架 我想在一个页面后退时 也就是点击浏览器的后退按钮时 这个被后退的页面重新加载 而不是读取缓存 我在这个页面对应的控制器方法中添加了 header("Cache-Control: no-cache, must-revalidate"); 但是cache_control不起作用 为啥

我用的是thinkphp 框架 tp的框cache_control 默认是private 所以我在控制器里设置不起作用 我改了在配置文件 就可以了

<code>header("Cache-Control: no-store, no-cache, must-revalidate");
header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); //过去的时间</code>
Copy after login

看鸟哥的这篇文章:http://www.laruence.com/2010/03/05/1332.html,对于刷新、F5,后退都是不一样的,你这种情况确实是使用缓存,而不是重新下载

Related labels:
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Issues
Why thinkphp has better performance than laravel?
From 1970-01-01 08:00:00
0
0
0
ThinkPHP Why use composer?
From 1970-01-01 08:00:00
0
0
0
thinkphp versions supported by php6
From 1970-01-01 08:00:00
0
0
0
thinkphp upload files
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template