Home > php教程 > php手册 > body text

用php控制页面的过期时间

WBOY
Release: 2016-06-06 19:55:36
Original
1302 people have browsed it

欢迎进入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控制页面的过期时间

source:php.cn
Statement of this Website
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
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!