获取缓存响应 - no-cache headers 未按预期工作

Fetch caching response - no-cache headers not working as expected

我一直在为 freecodecamp 做 random quote machine 项目,我似乎无法停止缓存 api 的响应。

我试过各种答案:

我以为我曾经有过:

fetch(this.url, {cache: 'no-cache'})
    .then(res => res.json())

...但我只是在开发人员工具中禁用了缓存。

请帮忙。 :-D.

这是我一直在努力让它发挥作用的地方: https://codepen.io/JonathanDWood/pen/gRNNKx

我已通过将 Date.now() 附加到 url 来修复它。我不太喜欢将它作为永久解决方案,因为它没有解决潜在的缓存问题,但它确实有效。

fetch(this.url+ Date.now(), {cache: 'no-store'})
    .then(res => res.json())