kiwi1342 kiwi1342 - 4 months ago 40
HTTP Question

Cache control not working when hit refresh in the browser

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?



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).