萬盛學電腦網

 萬盛學電腦網 >> 網頁制作 >> 腳本Html教程 >> 禁止頁面緩存的幾種方法

禁止頁面緩存的幾種方法

今天在開發時碰到一種方法,就是客戶要求頁面不緩存,查了一下得出如下幾種不讓頁面緩存的辦法


html
只要加在頭部就可以了.

<HEAD>  
    <META     HTTP-EQUIV="Pragma"     CONTENT="no-cache">  
    <META     HTTP-EQUIV="Cache-Control"     CONTENT="no-cache">  
    <META     HTTP-EQUIV="Expires"     CONTENT="0">  
    </HEAD> 

asp教程做法

Response.Buffer     =     True  
    Response.ExpiresAbsolute     =     Now()     -     1  
    Response.Expires     =     0  
    Response.CacheControl     =     "no-cache"  
    Response.AddHeader     "Pragma",     "No-Cache" 

php教程做法

 

<?php 
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); 
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . 'GMT'); 
header('Cache-Control: no-cache, must-revalidate'); 
header('Pragma: no-cache'); 
?>

還有一種更簡單的方法,就是大家ajax時用到的?mt=隨便數據

copyright © 萬盛學電腦網 all rights reserved