gpt4 book ai didi

javascript - 获取 API 缓存模式

转载 作者:数据小太阳 更新时间:2023-10-29 03:49:49 26 4
gpt4 key购买 nike

根据spec , fetch api有多种缓存模式。 (“default”、“no-store”、“reload”、“no-cache”、“force-cache”和“only-if-cached”)但是,尚不清楚每种模式的用途,或者浏览器支持的状态。

最佳答案

您可以在此处查看 polyfill 的文档:https://fetch.spec.whatwg.org/

它确实解释了每个值的含义

"default" Fetch will inspect the HTTP cache on the way to the network. If there is a fresh response it will be used. If there is a stale response a conditional request will be created, and a normal request otherwise. It then updates the HTTP cache with the response. [HTTP]

"no-store" Fetch behaves as if there is no HTTP cache at all.

"reload" Fetch behaves as if there is no HTTP cache on the way to the network. Ergo, it creates a normal request and updates the HTTP cache with the response.

"no-cache" Fetch creates a conditional request if there is a response in the HTTP cache and a normal request otherwise. It then updates the HTTP cache with the response.

"force-cache" Fetch uses any response in the HTTP cache matching the request, not paying attention to staleness. If there was no response, it creates a normal request updates the HTTP cache with the response.

关于javascript - 获取 API 缓存模式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31601167/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com