PHP set up Dynamic Web pages in the browser cache static Web page and Dynamic Web page dynamic Picture page dynamic picture system

Source: Internet
Author: User
Tags set time
Many people may not know that dynamic Web pages can also be cached in the browser. The following is a PHP script as an example of how to set up a dynamic Web page in the browser cache

Set page expiration time to 1 hours

$duetime = 3600*24*30;

//Get browser will transfer to server last-modified Header

$modify _time = $_server[' http_if_modified_since ');

//When the browser accesses the webpage again within the set time, send the HTTP 304 status code, which saves the amount of data transferred.

if (Strtotime ($modify _time) + $duetime > Time ())

{

Header (' http/1.1 304 ');

Exit (1);

}

Header (' connection:keep-alive ');

//Set up Web pages last-modified Header

Header (' last-modified: '. Gmdate (' d, D M Y h:i:s '). ' GMT ');

Set Page Expiration time

Header (' Expires: '. Gmdate (' d, D M Y h:i:s ', time () + $duetime). ' GMT ');

//execute cache for a long time, with Expires a bit similar, allows us to more fully control the page expiration time, because the browser time may not be coordinated with the server time, with Cache-control header can be limited

Header (' cache-control:max-age= '. $duetime);

Output content

......

?>

Original: http://woqilin.blogspot.com/2014/05/php.html

The above describes the PHP settings Dynamic Web page in the browser cache, including dynamic Web pages, browser content, I hope to be interested in PHP tutorial friends helpful.

  • 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.