Home > Backend Development > PHP Problem > How to clear page cache in php?

How to clear page cache in php?

青灯夜游
Release: 2023-03-05 09:08:01
Original
3696 people have browsed it

How to clear the page: use "header("Last-Modified:".gmdate("D,d M Y H:i:s" )."GMT");header("Cache-Control:no- cache,must-revalidate");" is enough.

How to clear page cache in php?

Recommendation: "PHP Video Tutorial"

During the development process, we often encounter page caching problems (Especially the html cache); after refreshing, the data is still the old version, and the data is still the old version after refreshing. I slowly start to doubt my life, haha; so during the development process, we need to clear the cache in time every time.

Add a few lines of code to solve this problem and control browser cache

header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . "GMT");
header("Cache-Control: no-cache, must-revalidate");
header("Pragma: no-cache");
Copy after login

Method 2:

header("Cache-Control: no-cache, must-revalidate");
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Content-Type: application/xml; charset=utf-8");
Copy after login

The above is the detailed content of How to clear page cache 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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template