Cache control not working when hit refresh in the

2019-09-04 06:15发布

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:

first

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:

second

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条回答
贼婆χ
2楼-- · 2019-09-04 06:50

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

查看更多
登录 后发表回答