admin管理员组文章数量:1426048
I've been doing the random quote machine project for freecodecamp and I can't seem to stop the response from the api being cached.
I've tried various answers:
- fetch(), how do you make a non-cached request?
I thought I had it at one point:
fetch(this.url, {cache: 'no-cache'})
.then(res => res.json())
... but I was just disabling the cache in developer tools.
Please help. :-D.
Here is where i've been trying to make it work:
I've been doing the random quote machine project for freecodecamp and I can't seem to stop the response from the api being cached.
I've tried various answers:
- fetch(), how do you make a non-cached request?
- https://forum.freecodecamp/t/apis-and-the-random-quote-machine-not-even-sure-what-to-ask/65982/13
I thought I had it at one point:
fetch(this.url, {cache: 'no-cache'})
.then(res => res.json())
... but I was just disabling the cache in developer tools.
Please help. :-D.
Here is where i've been trying to make it work: https://codepen.io/JonathanDWood/pen/gRNNKx
Share Improve this question edited Jul 24, 2017 at 0:54 Jon Wood asked Jul 23, 2017 at 16:02 Jon WoodJon Wood 1,76115 silver badges25 bronze badges1 Answer
Reset to default 4I have managed to fix it by appending Date.now()
to the url. I don't really like it as a permanent solution as it doesn't address the underlying caching issue but it works.
fetch(this.url+ Date.now(), {cache: 'no-store'})
.then(res => res.json())
本文标签: javascriptFetch caching responsenocache headers not working as expectedStack Overflow
版权声明:本文标题:javascript - Fetch caching response - no-cache headers not working as expected - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745369195a2655658.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论