当然,前提要先打开cdn中一个功能reload_into_ims on.这样用户发送过来no-cache也不怕了.因为这样会给给no-cache转成if-modified-since .所以我们写程序主要是对if-modified-since控制就好了.记的,缓存系统架构中计中最好是后端来控制,所以最好的方法是程序来管理过期.呵,我只会php,就用php写一个,别的程序也是一样
见我下面的程序,呵呵,5分钟过期.
<?php
$headers = apache_request_headers();
$client_time = (isset($headers['if-modified-since']) ? strtotime($headers['if-modified-since']) : 0);
$now=gmmktime();
$now_list=gmmktime()-60*5;
if ($client_time<$now and $client_time >$now_list){
header('last-modified: ‘.gmdate('d, d m y h:i:s', $client_time).' gmt', true, 304);
exit(0);
}else{
header('last-modified: ‘.gmdate('d, d m y h:i:s', $now).' gmt', true, 200);
}
?>
如对本文有疑问,
点击进行留言回复!!
相关文章:
-
-
-
-
-
-
-
荐
数据库的设计
数据库的设计一 为什么需要规范的数据库设计数据库设计的步骤收集信息标识实体标识每个实体需要存储的详细信息标识实体...
[阅读全文]
-
-
-
-
网友评论