How to prevent “304 Not Modified” in nginx?

南笙酒味 提交于 2019-12-22 04:00:13

问题


I'm trying to disable all the caches in nginx for testing purpose.

I've set the following line

add_header Cache-Control no-cache;

I see that the page itself is not cached, but the images, css, and javascripts are. I suspect that this is because Firefox is getting "304 Not Modified" header.

Is there a way to prevent it?

P.S:

I think I found it myself. Firefox shows '200 OK' all the time now.

Is this correct way?

I've added

if_modified_since off;
add_header Last-Modified "";

回答1:


Sounds right to me.

If the agent (in this case Firefox) says 200 OK, it means the transfer happened.




回答2:


Another way is to use a location directive:

location ~ \.(html|css|js)(.*)$ {
    expires -1;
    add_header Cache-Control no-store;
}



回答3:


Another way is doing ctrl + f5



来源:https://stackoverflow.com/questions/7654773/how-to-prevent-304-not-modified-in-nginx

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!