How to disable page caching in PHP _ PHP Tutorial

Source: Internet
Author: User
PHP disables page caching. PHP disables page caching. for example, if I have three pages. shopping cart 2. order address and payment method 3. when the order is generated 2-3, the order data is inserted to generate the order information and the PHP method to disable page caching.

For example, I have 3 pages, 1. shopping cart 2. order address and payment method 3. when order generation 2-> 3 is displayed, the order data is inserted to generate order information and items under the order, and the corresponding item data of the shopping cart is cleared.

If you do not want the user to go to the last page, the order has been generated, and then click the return button of the browser to return to the previous page.

On the order address page, add:

Header ("Cache-Control: no-cache, must-revalidate, no-store"); // This no-store is valid in Firefox after it is added.

Header ("Pragma: no-cache ");

Header ("Expires:-1 ");

This page is no longer cached, and a page will jump to the empty shopping cart if it is determined that the shopping cart item is empty. then, the user clicks the browser and returns to the shopping cart page.

Detailed description:

Click the back button to read the cached files in the browser. you can use the cache to disable the back button.

Method: Add the following code in.

  

Expires (term). description: it can be used to set the expiration time of a webpage. Once the webpage expires, it must be re-transmitted to the server.

Usage:

Note: the GMT time format must be used.

Content = "-1", web pages cannot be cached at any time.

  

  

When you access a webpage for the first time, the computer automatically caches the content of the webpage. when you access the same url for the second time, the browser directly calls the original cache, even if your new website is updated, the earlier version is displayed. If it is set to no-catch, local data will not be cached, that is, each request is in the latest version.

However, the preceding three statements are valid in IE and invalid in FF, and the following sentence is added in FF.

  

There are many ways to disable the back button. this method is only one of them.

For example, if I have 3 pages, 1. shopping cart 2. Order address and payment method 3. when the order is generated 2-3, the order data is inserted to generate order information and...

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.