Good afternoon everyone, I read in the book that header("Cache-Control:no-cache") can force the browser not to use cache, so I wanted to test the effect. The code is as follows:
<code><?php header("Pragma:no-cache"); header("Cache-Control:no-cache,must-revalidate"); ?> <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Document</title> </head> <body> <img src="1.jpg" alt=""> </body> </html> </code>
But I didn’t see the expected effect. Every time I refreshed the page, 304 was returned. Why not 200?
It’s really hard to guess. . .
Good afternoon everyone, I read in the book that header("Cache-Control:no-cache") can force the browser not to use cache, so I wanted to test the effect. The code is as follows:
<code><?php header("Pragma:no-cache"); header("Cache-Control:no-cache,must-revalidate"); ?> <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Document</title> </head> <body> <img src="1.jpg" alt=""> </body> </html> </code>
But I didn’t see the expected effect. Every time I refreshed the page, 304 was returned. Why not 200?
It’s really hard to guess. . .
html isn’t it 200 anymore? .
jpg is a static file, it is returned in apache/nginx without using php at all, and the cache is also handled by the server.
Clear browser cache.
The first time it is loaded, 200 is returned. If there are no changes on the server side, 304 will be returned.
If you want to force refresh the page, press Ctrl+F5 on Google Chrome.
Check if your web server (such as nginx) has cache enabled.