Home > Article > Backend Development > How to clear page cache in php?
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.
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!