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

How to clear page cache in php?

青灯夜游
青灯夜游Original
2020-08-26 11:53:133630browse

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");

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");

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!

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