/*
利用304缓存php页面的函数 , (axgle写的函数明显的逻辑错误)
bailing
2006-11-02
*/

set_cache_limit(20);
echo date("Y-m-d H:i:s");

function set_cache_limit($second=1)
{
	$second=intval($second); 
	if($second==0) {
		return;
	}
	
	$id = $_SERVER['HTTP_IF_NONE_MATCH'];
	$etag=time()."||".base64_encode( $_SERVER['REQUEST_URI'] );
	if( $id=='' )
	{//无tag,发送新tag
		header("Etag:$etag",true,200);	
		return;
	}
	list( $time , $uri )=explode ( "||" , $id );
	if($time < (time()-$second))
	{//过期了,发送新tag
		header("Etag:$etag",true,200);
	}else
	{//未过期,发送旧tag
		header("Etag:$id",true,304);	    
		exit(-1);
	}
} 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-09-05
  • 2021-12-16
  • 2021-11-06
  • 2021-09-05
猜你喜欢
  • 2021-11-26
  • 2021-07-10
  • 2022-12-23
  • 2022-12-23
  • 2022-01-30
  • 2022-12-23
相关资源
相似解决方案