How to disable page caching in php

藏色散人
Release: 2023-03-01 08:28:02
Original
3030 people have browsed it

How to disable page caching in php

#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:

Copy after login

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");
Copy after login

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!

Related labels:
php
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
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!