获取缓存响应 - 无缓存标头未按预期工作

Jon*_*ood 5 javascript ajax cache-control vue.js fetch-api

我一直在为 freecodecamp 做随机报价机项目,我似乎无法停止缓存 api 的响应。

我尝试过各种答案:

我以为我曾经有过这样的经历:

fetch(this.url, {cache: 'no-cache'})
    .then(res => res.json())
Run Code Online (Sandbox Code Playgroud)

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

请帮忙。:-D。

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

Jon*_*ood 4

我已经设法通过附加Date.now()到网址来修复它。我真的不喜欢它作为永久解决方案,因为它没有解决底层缓存问题,但它有效。

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