How php disables browsers from caching pages
Page caching is not required sometimes. We can disable the browser from caching the page.
In PHP, you can easily use the following statement to disable page caching, but it is difficult to remember it for your convenience.
The php code is as follows:
The Code is as follows:
<? Php
// Set the expiration time of this page (expressed by Greenwich Mean Time), as long as it is a date that has passed.
Header ("Expires: Mon, 26 Jul 1970 05:00:00 GMT ");
// Set the last update date (expressed by Greenwich Mean Time) on this page to the current day. You can force the browser to obtain the latest information.
Header ("Last-Modified:". gmdate ("D, d m y h: I: s"). "GMT ");
// Tell 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 and is compatible with the HTTP 1.0 Protocol
Header ("Pragma: no-cache ");
?>
This is useful for some pages, such as single information and items under the order, and clearing the corresponding item data of the shopping cart.
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:
The Code is as follows:
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.