Setting Cache-Control pubic not caching xhr

爱⌒轻易说出口 提交于 2020-01-16 08:54:08

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!