zoukankan      html  css  js  c++  java
  • php禁止页面缓存的函数

    function nocache_headers() {  
    @ header('Expires: Thu, 01 Jan 1970 00:00:01 GMT');  
    @ header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');  
    @ header('Cache-Control: no-cache, must-revalidate, max-age=0');  
    @ header('Pragma: no-cache');  
    }  
    nocache_headers(); 

    Html+Asp+Php+Jsp:4种语言禁止浏览器缓存页面的方法

    HTTP:
    <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">
    <META HTTP-EQUIV="expires" CONTENT="0">

    ASP
    response.expires=0
    response.addHeader("pragma","no-cache") 
    response.addHeader("Cache-Control","no-cache, must-revalidate")

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

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

    php禁止浏览器使用缓存页面 
    Code
    1<?php    
    2   
    3//设置此页面的过期时间(用格林威治时间表示),只要是已经过去的日期即可。    
    4header("Expires: Mon, 26 Jul 1970 05:00:00 GMT");      
    5   
    6//设置此页面的最后更新日期(用格林威治时间表示)为当天,可以强制浏览器获取最新资料     
    7header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");      
    8   
    9//告诉客户端浏览器不使用缓存,HTTP 1.1 协议     
    10header("Cache-Control: no-cache, must-revalidate");      
    11   
    12//告诉客户端浏览器不使用缓存,兼容HTTP 1.0 协议     
    13header("Pragma: no-cache");    
    14   
    15?> 

    转自:http://www.cnblogs.com/zfying/archive/2012/07/21/2602004.html

  • 相关阅读:
    Python 爬虫入门(一)
    Dubbo、Zookeeper集群搭建及Rose使用心得(二)
    Dubbo、Zookeeper集群搭建及Rose使用心得(一)
    JAVA 加密算法初探DES&AES
    Android 蓝牙模块基础操作
    IntelliJ IDEA 使用随笔
    Maven+SSM框架实现简单的增删改查
    记录一次bug解决过程:数据迁移
    SSM框架+Plupload实现断点续传(Spring+SpringMVC+MyBatis+Plupload)
    JAVA开发环境
  • 原文地址:https://www.cnblogs.com/yiwd/p/2982420.html
Copyright © 2011-2022 走看看