Dynamic web page design that can be cached in PHPSquid _ PHP Tutorial

Source: Internet
Author: User
Dynamic web page design that can be cached in PHPSquid. Of course, you must first enable reload_assist_imson in CDN. in this way, no-cache is not used. this will convert no-cache to If-Modified-Since. therefore, to write the program master, 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 );
}
?>

Login on. in this way, the user will not be afraid of sending no-cache, because it will convert no-cache to If-Modified-Since. so we write the program main...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.