Home > Article > Backend Development > PHP code introduction to disable page caching_PHP tutorial
The code to disable page caching in php is quite simple. Just use the php header() browser to send a Cache-Control: no-cache or set the page cache expiration time to before today.
A friend said the following is the simplest way to disable page caching
代码如下 | 复制代码 |
header("Cache-Control: no-cache, must-revalidate"); |
Here I will first give you a piece of php code that can be used:
The code is as follows
|
Copy code
|
||||||
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); header("Cache-Control: no-cache, must-revalidate"); header("Pragma: no-cache"); Let’s first understand the HTTP response message. In fact, we can use the Telnet command to view it. Below I will give some HTTP response content: HTTP/1.1 200 OK Server:Microsoft-IIS/6.0 Date: Thu, 31 Oct 2008 11:20:53 GMTContent-Type: text/html Set-Cookie: name=value; path=/
|
The code is as follows | Copy code |