Home > Article > Backend Development > Dynamic Web Design Cacheable Dynamic Web Design in PHP Squid
Of course, the prerequisite is to turn on a function reload_into_ims on in the CDN first. In this way, users will not be afraid of sending no-cache. Because this will convert the no-cache into If-Modified-Since. So we write the program 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 program is the same
See my program below, haha, it expires in 5 minutes.
$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 has introduced the dynamic web design that can be cached in PHP Squid, including the content of dynamic web design. I hope it will be helpful to friends who are interested in PHP tutorials.