Home > Backend Development > PHP Tutorial > How to disable page caching in PHP_PHP tutorial

How to disable page caching in PHP_PHP tutorial

WBOY
Release: 2016-07-13 10:23:50
Original
935 people have browsed it

How to disable page caching in PHP

For example, I have 3 pages, 1. Shopping cart 2. Order address and payment method 3. Display order generation 2 -> 3 At that time, the order data is inserted, the order information and the products under the order are generated, and the corresponding product data in the shopping cart is cleared.

You definitely don’t want the user to reach the last page and have already generated an order, and then click the browser’s return button to return to the previous page.

Then add on the order address page:

Header("Cache-Control:no-cache,must-revalidate,no-store"); //After adding this no-store, it will be valid under Firefox

header("Pragma:no-cache");

header("Expires:-1");

This page is no longer cached, and there is a page that will jump to the empty shopping cart if the items in the shopping cart are empty. Then the user clicks the browser to go back, and when he comes back, he will go directly to the shopping cart page.

Detailed description:

Clicking the back button reads the cache file in the browser, so you can use the cache to disable the back button.

Method: Add the following code inside.

 

Expires, description: can be used to set the expiration time of the web page. Once a web page expires, it must be retransmitted to the server.

Usage:

Note: GMT time format must be used.

Content="-1", the web page cannot be stored by Cache at any time.

 

 

When you visit a webpage for the first time, the computer will automatically cache the content of the webpage. When you visit the same URL for the second time, the browser will directly bring up the original cache. Even if your new website is updated, it will be displayed. It's still the same version as before. If set to no-catch, it will not be cached locally, that is, the latest version will be requested every time.

But the above three sentences are valid in IE, but invalid in FF. In FF, add the following sentence.

 

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

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/834964.htmlTechArticleHow to disable page caching in PHP. For example, I have 3 pages, 1. Shopping cart 2. Order address and payment method 3. When order generation 2 - 3 is displayed, insert the order data, generate order information and...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template