Php中网页如何禁止缓存


rt

php 缓存技术

z14754 13 years, 3 months ago

HTM 网页

  <META  HTTP-EQUIV="pragma"  CONTENT="no-cache">
  <META  HTTP-EQUIV="Cache-Control"  CONTENT="no-cache,  must-revalidate">
  <META  HTTP-EQUIV="expires"  CONTENT="Wed,  26  Feb  1997  08:21:57  GMT">

ASP 网页

  <%
  Response.Expires  =  -1
  Response.ExpiresAbsolute=Now()-1
  Response.cachecontrol = "no-cache"
  %>

或者

  <%
  response.expires=0
  response.addHeader("pragma","no-cache")
  response.addHeader("Cache-Control","no-store, must-revalidate")
  %>

PHP 网页

  <?
  header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
  header("Cache-Control: no-store, must-revalidate");
  header("Pragma: no-cache");
  ?>

JSP网页

  response.addHeader("Cache-Control", "no-store, must-revalidate");
  response.addHeader("Expires", "Thu, 01 Jan 1970 00:00:01 GMT");

asp.net(C#)网页

  Response.Buffer=true;
  Response.ExpiresAbsolute=System.DateTime.Now.AddSeconds(-1);
  Response.Expires=0;
  Response.CacheControl="no-cache";

禁止图片缓存

在图片后面加一个随机参数,如:

  <img src=”images/bg.gif?temp_id=156404 />
聰明的小帥哥 answered 13 years, 3 months ago

Your Answer