1. Use header() to set the expiration time.
2. Use header() to set the last updated date of the page to today, which can force the browser to obtain the latest information.
3. Use header() to tell the client browser not to use caching.
Example
<?php //Set the expiration time of this page (expressed in Greenwich Mean Time), as long as it is a date that has passed. header("Expires: Mon, 26 Jul 1970 05:00:00 GMT"); //Set the last updated date of this page (expressed in Greenwich Mean Time) to today, which can force the browser to obtain the latest information header("Last-Modified: " . gmdate("D, d M Y H:i:s") . "GMT"); //Tell the client browser not to use cache, HTTP 1.1 protocol header("Cache-Control: no-cache, must-revalidate"); //Tell the client browser not to use cache and be compatible with HTTP 1.0 protocol header("Pragma: no-cache"); ?>
The above is how PHP uses header() to disable caching. I hope it will be helpful to everyone. More PHP learning guide: source code network