Cache control not working when hit refresh in the browser

社会主义新天地 提交于 2019-12-12 04:33:11

问题


I'm trying to implement cache control on my application. I've set up the tomcat filter for the all fonts giving a max-age=120.

When I request a font for the first time with the cache cleared, the call/response is the following:

and as you can see I have the max-age response. Now I expect that if I hit refresh the browser won't send the http request again instead this is what happens:

As you can see the second request has a

cache-control: max-age=0

value and the response is returned from the server cache. What I'm trying to achieve is to block the entire call from the browser.

Am I doing something wrong?

Thanks


回答1:


Hitting refresh has semantics that are dependent upon the browser you're using, but often it will make a conditional request to make sure the user is seeing a fresh response (because they wanted to refresh).

If you want to check cache operation, try navigating to the page, rather than hitting refresh.

OTOH if you don't want refresh to behave like this -- and you really mean it -- Mozilla is prototyping Cache-Control: immutable to do this (but it's early days, and mob-only for the moment).



来源:https://stackoverflow.com/questions/40151783/cache-control-not-working-when-hit-refresh-in-the-browser

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