Home  >  Article  >  php教程  >  用php控制页面的过期时间

用php控制页面的过期时间

WBOY
WBOYOriginal
2016-06-06 19:55:361301browse

欢迎进入Linux社区论坛,与200万技术人员互动交流 >>进入 用php控制页面的过期时间: 控制页面的过期主要是对If-Modified-Since控制. 下面的程序实现页面5分钟后过期 ?php $headers = apache_request_headers(); $client_time = (isset($headers['If-Modified

欢迎进入Linux社区论坛,与200万技术人员互动交流 >>进入

    用php控制页面的过期时间:

    控制页面的过期主要是对If-Modified-Since控制.

    下面的程序实现页面5分钟后过期

   

    $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_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);

    }

    ?>

用php控制页面的过期时间

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn