PHP prevents browsers from using cached pages _php tutorial

Source: Internet
Author: User
Tags browser cache

How PHP prohibits browsers from using cached pages


Page slow exists sometimes is not necessary, we can prohibit the browser cache page.

In PHP can easily use the following statement to implement prohibit page caching, but it is difficult to remember the special arrangement, convenient for everyone to use.
The PHP code is as follows:

The code is as follows:

Set the expiration time for this page (in GMT), as long as the date has passed.
Header ("Expires:mon, Jul 1970 05:00:00 GMT");
Set the last update date for this page (expressed in GMT) to force the browser to get the latest information for the current day
Header ("last-modified:".) Gmdate ("D, D M Y h:i:s"). " GMT ");

Tells the client browser not to use the cache, HTTP 1.1 protocol
Header ("Cache-control:no-cache, must-revalidate");

Tells the client browser not to use the cache, compatible with the HTTP 1.0 protocol
Header ("Pragma:no-cache");
?>


This is useful for some pages, such as single information and items under orders, and emptying the cart for product data.
Certainly do not want users to the last page, have already generated orders, and then click the browser's return button back to the previous page.
Then on the Order Address page, add:

The code is as follows:

Header ("Cache-control:no-cache,must-revalidate,no-store"); After this no-store is added, Firefox works
Header ("Pragma:no-cache");
Header ("Expires:-1");


This page does not cache, and there is a judgment shopping cart product is empty jump to empty shopping cart page, then the user click the browser back, back, also directly to the shopping cart page.

http://www.bkjia.com/PHPjc/907714.html www.bkjia.com true http://www.bkjia.com/PHPjc/907714.html techarticle PHP prevents browsers from using cached pages in a way that is sometimes unnecessary, and we can disallow browsers from caching pages. In PHP, it is easy to use the following statement in real ...

  • Related Article

    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.