Home > Backend Development > PHP Tutorial > Top Ten Web Game Rankings 2013 PHP Code to Control Web Page Expiration Time

Top Ten Web Game Rankings 2013 PHP Code to Control Web Page Expiration Time

WBOY
Release: 2016-07-29 08:38:55
Original
2103 people have browsed it

Of course, the prerequisite is to turn on reload_into_ims on, a function in CDN. In this way, users will not be afraid of sending no-cache. Because this will convert no-cache into If-Modified-Since. So we write programs mainly for If-Modified -Since control is fine. Remember, in the cache system architecture, it is best to be controlled by the backend, so the best way is to manage expiration by program. Hehe, I only know PHP, so I will use PHP to write one. The same goes for programs.
See my program below, haha, it expires in 5 minutes.

Copy the code The code is as follows:


$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);
}
? >

The above introduces the top ten web game rankings in 2013. The PHP code for controlling the expiration time of web pages, including the top ten web game rankings in 2013. I hope it will be helpful to friends who are interested in PHP tutorials.

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 Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template