页面不缓存的方法no-cache
1.使用meta标签
下面几个标签的介绍,具体用法下面有
<meta http-equiv="Pragma" content="no-cache">
禁止浏览器从本地机的缓存中调阅页面内容,设定后一旦离开网页就无法从Cache中再调出;
<meta http-equiv="cache-control" content="no-cache">
常见值:private、no-cache、max-age、must-revalidate
在地址栏回车 值为private或must-revalidate则只有第一次访问时会访问服务器,以后就不再访问。 值为no-cache,那么每次都会访问。 值为max-age,则在过期之前不会重复访问。按后退按扭 值为private、must-revalidate、max-age,则不会重访问, 值为no-cache,则每次都重复访问
过期时间,0表示立即过期
<meta http-equiv="expires" content="0">
示例:
<meta http-equiv="Pragma" content="no-cache">
<meta http-equiv="Cache-Control" content="no-store, no-cache, must-revalidate, post-check=0, pre-check=0">
<meta http-equiv="Expires" content="0">
还有一些情况,就是不想缓存某张图片,其他的不管它,这种情况其实也好处理
就是在图片的后面加上一段随机数,这样每次请求的地址是不一样的,所以就不缓存了,示例如下:
<img src="test,jpg<?php echo rand(100,999);?>">