元问答栏目交友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.