Home  >  Article  >  Backend Development  >  Problem with header("Cache-Control:no-cache")

Problem with header("Cache-Control:no-cache")

WBOY
WBOYOriginal
2016-09-09 08:28:032024browse

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:





    
    Document

But I didn’t see the expected effect. Every time I refreshed the page, 304 was returned. Why not 200?

Problem with header(

It’s really hard to guess. . .

Reply content:

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:





    
    Document

But I didn’t see the expected effect. Every time I refreshed the page, 304 was returned. Why not 200?

Problem with header(

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.

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