admin管理员组文章数量:1326277
We have a REST api which works in Chrome but we found that cached results are used in IE.
In order to fix customers have to go to internet options and change the setting 'Check for the newer version of stored pages" to 'Every time I visit the web page'.
I have seen that I could put at datetime at the end of each of my requests using javascript like so
/v1/getInfo?Date = (new Date())
However this means I have to tell all the customers to do this.
Is there a better way of doing this so that my requests look like
/v1/getInfo
without changing the URL?
We have a REST api which works in Chrome but we found that cached results are used in IE.
In order to fix customers have to go to internet options and change the setting 'Check for the newer version of stored pages" to 'Every time I visit the web page'.
I have seen that I could put at datetime at the end of each of my requests using javascript like so
/v1/getInfo?Date = (new Date())
However this means I have to tell all the customers to do this.
Is there a better way of doing this so that my requests look like
/v1/getInfo
without changing the URL?
Share Improve this question asked Jul 8, 2015 at 15:13 JD.JD. 15.6k22 gold badges92 silver badges165 bronze badges 1- You can add HTTP headers to instruct the browser not to cache. – Lloyd Commented Jul 8, 2015 at 15:15
2 Answers
Reset to default 4For this task, you should set up the correct HTTP Headers in your application. The caching is controlled by the Cache-Control
header:
Cache-Control: no-cache
Though in itself, this is not bulletproof, so you may need to set up other headers too. This guide seems like a nice writeup.
Check what headers your API is returning. In particular check the configuration of Expires and Cache-Control headers. Those are what inform browsers/clients to store a local copy of the message body and to use that next time they request the same resource.
本文标签: javascriptHow to avoid caching in IE with REST ApiStack Overflow
版权声明:本文标题:javascript - How to avoid caching in IE with REST Api? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742213115a2434078.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论