元问答栏目交友PWA好句收藏好句+提问
MY简/繁
  1. 编程问答
  2. 答案列表
  3. 答案正文

怎么解决:Failed to execute put on Cache :Request method POST is unsupported[朗读]

回答:1 2022-08-01 17:17:58
@content
很简单,加上判断就行,如果是get请求就缓存,不然就不缓存。
self.addeventlistener('fetch',event =>{
event.respondwith(。
caches.match(event.request).then(response =>{
if (response) {
//found cached resource
return response;
}
// get resource and add it to cache
return fetch(event.request)。
then(response =>{
// check if the response is valid
if (!response.ok) {
return response;
}
if(event.request.method=='get'){
const newresponse = response.clone();
caches.open(cache_name).then(cache =>cache.put(event.request,newresponse)。
);
}
return response;
});
})。
);
});
2022-08-01 17:17:58
顶0

加入收藏

相关问答推荐
[荐]性感美女时尚写真,清纯漂亮
HOT!
怎样查询当前访问的CloudFlare节点信息
2022-08-01答 1
如何进行web前端性能优化
2022-08-01答 1
Web前端最新优化指标有哪些
2022-08-01答 1
怎么改善网站上最大的内容绘制 LCP
2022-08-01答 1
seo是什么
2022-08-01答 3
seo是什么意思,还有用吗
2022-08-01答 1
阿里云建站怎么样
2022-08-01答 1
zip64压缩文件密码破解
2022-07-24答 1
zip文件密码破解 zip压缩包密码破解
2022-07-22答 1
zip64解压软件
2022-07-22答 1
[荐]二级网站(个人博客)在线申请
HOT!
我来回答
栏目大全RSS
经纬度查询
隐私政策
跨年文案名句大全
打麻将文案名句大全
戏精搞笑文案名句大全
元旦祝福语名句大全
大爱无疆名句大全
结婚文案名句大全
结婚贺词名句大全
幽默文案名句大全
搞笑文案名句大全
心灵鸡汤语录名句大全
名句精选
豆奶短视频-您懂的
猜你喜欢
1、c反应蛋白值20且伴有咳嗽应如何处理
2、如何减轻牙颈部外露导致的疼痛
3、舌头灼热感应该吃什么食物
4、下颌角内部硬物导致疼痛的原因是什么
5、嘴内出现白色肉球的可能原因是什么
6、安装吸附式假牙需要满足哪些条件
7、如何清洁门牙的舌侧
8、根管长度超标后如何处理
9、大量饮水后口唇干燥的原因是什么
10、智齿会引起感冒流涕症状吗
中文静网 匿名发推

Copyright © lcget All Rights Reserved.