网页缓存由HTTP消息头中的Cache-control控制,常见取值有private、no-cache、max-age、must- revalidate等,默认为private。
浏览器的访问方式分为以下几种:
1,打开一个新窗口
此种情况下,private,no-cache,must-revalidate都会重新访问服务器
max-age在设定的时间内不会重新访问。如max-age=5,则在5秒时间内不会访问服务器
2,在地址栏输入地址回车
此种情况下,private,must-revalidate都会在第一次时重新访问服务器
max-age在设定的时间内不会重新访问。如max-age=5,则在5秒时间内不会访问服务器
no-cache重新访问服务器
3,刷新页面时
都会重新访问服务器
4,按backspace后退键时
private,must-revalidate,max-age 不会访问服务器
no-cache重新访问服务器
如下代码:
header('cache-control:private,must_revalidate');
?>
可以控制缓存