PHPSquid can be cached in the dynamic web page design, read PHPSquid can be cached in the dynamic web page design, sometimes we need to control the homepage and other web page Expiration Time. for example, if we use Chinacache CDN, how should we design it so that it can cache my content. of course, you must first enable reload_assist_imson in CDN. in this way, the user has sent "> <LINKhr
Sometimes we need to control the expiration time of webpages such as the home page. but for example, if we use Chinacache CDN, how can we design it so that it can cache my content.
Of course, you must first enable the reload_assist_ims on function in CDN. in this way, no-cache is not used. this will convert no-cache to If-Modified-Since. therefore, we can write a program to control If-Modified-Since. note: in the cache system architecture, it is best to control the backend, so the best way is to manage the expiration by the program. well, I only use php to write one, and other programs are the same.
See my program below. it will expire 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 );
}
?>