#How to disable page caching in php?
Page caching is sometimes not needed. We can prevent 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 and organize it for everyone's convenience.
The php code is as follows:
This is very useful for certain pages, such as order information and products under the order, and clearing the corresponding product data in the shopping cart.
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"); //这个no-store加了之后,Firefox下有效 header("Pragma:no-cache"); header("Expires:-1");
This page is not 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 on the browser Go back and come back, and you will go directly to the shopping cart page.
Related recommendations: "PHP Tutorial"
The above is the detailed content of How to disable page caching in php. For more information, please follow other related articles on the PHP Chinese website!