PHP prevents browsers from using cached page methods

Source: Internet
Author: User
Tags php code

The slow existence of pages is sometimes unwanted, and we can prevent browsers from caching pages.

In PHP, you can easily use the following statement to achieve the prohibition of page caching, but more difficult to remember the special collation, convenient for everyone to use.
The PHP code is as follows:

The code is as follows: <?php
Set the expiration time for this page (expressed in GMT), as long as it is a date that is already past.
Header ("Expires:mon, June June 1970 05:00:00 GMT");
Set the last update date for this page (in Greenwich Mean Time) for the same day, you can force the browser to get the latest information
Header ("last-modified:"). Gmdate ("D, D M Y h:i:s"). " GMT ");

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

Tells the client that the browser does not use caching, which is compatible with the HTTP 1.0 protocol
Header ("Pragma:no-cache");

This is useful for some pages, such as a single message and a product under an order, and empty the cart's corresponding product data.
Certainly do not want users to the last page, have already generated orders, and then click the Return button browser back to the previous page.
Then in 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 is not cached, and there is a judge shopping cart merchandise to jump to empty shopping cart page, then the user clicks on the browser back, back, also directly to the shopping cart page.

Related Article

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

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: and provide relevant evidence. A staff member will contact you within 5 working days.