亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

php - Using http's Last-Modified cache to read cached files?
天蓬老師
天蓬老師 2017-05-16 13:14:43
0
1
802

Recently studied the Last-Modified cache mechanism using http, which allows the browser to read the cache file.
$num = 4; //Simulate server data changes to determine whether the browser needs to read the cache file
if($num==4) {

  if( isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) ){  
    $browserCachedCopyTimestamp = strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']);  
     if ( ( $browserCachedCopyTimestamp + 3600 ) > time() ) {  
        header("HTTP/1.1 304");  
        exit(1);  
     }  
  }  

}else{

    header('Last-Modified: '.gmdate('D, d M Y H:i:s',time())." GMT");  
    header('Expires: '.gmdate('D, d M Y H:i:s', time() + 3600)." GMT");  
    header("Cache-Control:max-age=3600");  
   
    for( $i=1; $i < 10 ; $i++ ){  
       echo "$i|";      
    }  

}
I tested above that the cache file can be read, but I just checked online and said it is

[Last-Modified and ETags request http headers are used together. The server first generates the Last-Modified/Etag tag. The server can later use it to determine whether the page has been modified and determine whether the file should continue to be cached]
Why use Last-Modified and ETags together? Don't understand.

天蓬老師
天蓬老師

歡迎選擇我的課程,讓我們一起見(jiàn)證您的進(jìn)步~~

reply all(1)
大家講道理

Quoting someone else’s answer link description

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template