The example in this article describes how PHP prevents browsers from using cached pages. Share to everyone for your reference. The specific methods are as follows:
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:
Copy Code code 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:
Copy Code code 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.
I hope this article will help you with your PHP program design.