问题
I have this setting in Chrome devtools:
this setting works for me. However, I also want to disable the cache for certain resources. My question is - is there a way to disable the cache for a resource when you use fetch?
fetch(url).then(v => {});
is there some option or header that we can use to prevent the browser from using the cache to retrieve the resource?
回答1:
This has the answers I was looking for:
https://hacks.mozilla.org/2016/03/referrer-and-cache-control-apis-for-fetch/
first make sure caching is disabled on the server, if necessary.
Then in the browser, we can use one of these:
fetch(url, {cache: 'no-store'})
or
fetch(url, {cache: 'no-cache'})
and get the result we want to achieve.
来源:https://stackoverflow.com/questions/48836369/disable-cache-for-certain-resource-programmatically