I'm looking for a way to force my index HTML page to be cached in the browser with a response of 200 (cached)
rather than a normal 200
or 304
response.
This question is very similar to Nginx - "force" 200 cache response instead of 304.
What I have tried:
I have tried sending these headers from my server:
Expires: (some date in the future)
Cache-Control: public
Pragma: public
Or:
Cache-Control: public, max-age=3600
But neither of these get the result I need.
Example site with working HTTP caching:
https://www.mozilla.org/en-GB/
On first load of the Mozilla website, everything is returned with a standard 200 response. On a refresh, all of the resources are loaded through the local cache (and the browser network tab shows a 200 (cached)
message).
The index page is sometimes loaded with a 200 OK
or 304
.
I want to know if it is possible to get my index page to load from the browser cache like the resources are on the Mozilla webpage. If it is possible, how can this be done?