今天在开发时碰到一种方法,就是客户要求页面不缓存,查了一下得出如下几种不让页面缓存的办法:
html:只要加在头部就可以了.
代码如下:
1 <HEAD>
2 <META HTTP-EQUIV="Pragma" CONTENT="no-cache">
3 <META HTTP-EQUIV="Cache-Control" CONTENT="no-cache">
4 <META HTTP-EQUIV="Expires" CONTENT="0">
5 </HEAD>
asp教程做法
代码如下:
1 Response.Buffer = True
2 Response.ExpiresAbsolute = Now() - 1
3 Response.Expires = 0
4 Response.CacheControl = "no-cache"
5 Response.AddHeader "Pragma", "No-Cache"
php教程做法
代码如下:
1 <?php
2 header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
3 header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . 'GMT');
4 header('Cache-Control: no-cache, must-revalidate');
5 header('Pragma: no-cache');
6 ?>