问题
I am trying to implement caching for XHR reponse with in theory the browser should go to server, and server can decide to send 304 - Not Modified if there is no new dynamic data and the browser would use the cache response from its previous request.
As per the theory, it could be done using no-cache
on Cache-Control
.
But first I tried to use, if at all I can make the browser store the response by setting response.set('Cache-Control', 'public, max-age=315360000, max-stale');
I can see, it in my xhr response (see the snapshot below), but every time I call the API, it is calling the server to get the response, instead the browser should have got the data from it's cache since the response headers are saying so.
Please let me know what I am missing to make this work.
Any help is appreciated.
来源:https://stackoverflow.com/questions/55700579/setting-cache-control-pubic-not-caching-xhr