I have set Cache control in my response header as Cache-Control:public, max-age=86400. But when I try to refresh page or open a new tab, it always hits my server. The response status I got is 200, server log is appeared for this request also I checked chrome://cache/ this request is not in the list. I already looked some similar SO questions cache-control not working without etag and why cache-control:max-age don't work?. But still with no luck. Tested on chrome 56.
6
votes
Are you also sending a Last-Modified and/or ETag header in the response?
- mwp
No, I didn't. As my understanding ETag is for validating same content on server to save bandwidth? But I don't want browser to make a request in the first place if cache is not expired.
- Mengo
I have the same problem, In my case i have a reverse proxy in place , which sets cache control to response headers . Although the headers get applied .chrome still hits the server
- Jeson Dias
Typical trap: Inspecting with chrome/firefox/etc. devtools disables the cache. Make sure that "Disable Cache" is not checked.
- Karsten S.
When you press Refresh (F5) then cache is cleared. Check more detailed answer here stackoverflow.com/questions/10518493/…
- Sergey Ponomarev
3 Answers
5
votes
1
votes