元问答栏目交友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、流氓之间为什么能成为朋友
2、为什么有钱人都喜欢移民去外国,中国有钱人不是很舒服吗
3、男人是用来干什么的
4、女孩子一旦被追到手后就不值钱了吗
5、体制内着装最忌讳的是什么
6、人品才华美貌,对于女人哪个更重要
7、专制统治一定灭亡吗
8、怎样高效追女人
9、为什么每次改朝换代都这么惨烈
10、婚烟长久的基础是什么
中文静网 匿名发推

Copyright © lcget All Rights Reserved.