[英]How to call certain apis without caching a response in angular when using service worker?
I Have attached 2 images.我附上了 2 张图片。 First Image is the very fist time when I load the website where the service-worker is registered.
第一张图片是我第一次加载注册 service-worker 的网站。 There are 2 arrow mark that shows 302 found and sets the cookies of session information.
有2个箭头,显示302 found,设置session信息的cookies。
This is the second time (refer the below image), After I sign out and sign in again using google i am getting the below image as a response.这是第二次(参考下图),在我退出并使用谷歌再次登录后,我得到下图作为响应。 You can see from the image there are no cookies set and it is actually from service worker.
你可以从图像中看到没有设置 cookies,它实际上来自 service worker。
This is my ngsw-config.json, from the docs Reference I have made it as "navigationRequestStrategy": "freshness", But still it doesnt work.这是我的 ngsw-config.json,来自文档参考,我将其设为“navigationRequestStrategy”:“新鲜度”,但它仍然不起作用。
{
"$schema": "./node_modules/@angular/service-worker/config/schema.json",
"index": "/index.html",
"navigationUrls": [
"! /**/*callback*"
],
"navigationRequestStrategy": "freshness",
"assetGroups": [
{
"name": "app",
"installMode": "prefetch",
"resources": {
"files": [
"/favicon.ico",
"/manifest.webmanifest",
"/*.css",
"/*.js"
]
}
},
{
"name": "assets",
"installMode": "lazy",
"updateMode": "prefetch",
"resources": {
"files": [
"/assets/**",
"/*.(eot|svg|cur|jpg|png|webp|gif|otf|ttf|woff|woff2|ani)"
]
}
}
]
}
So the service worker was caching the api response and returned from the cache.所以 service worker 正在缓存 api 响应并从缓存中返回。 To bypass the service worker for certain apis.
绕过某些 api 的 service worker。 Either add salt or use
ngsw-bypass
in the queryparams.在查询参数中添加盐或使用
ngsw-bypass
。
Bypass Service Worker Caching in APIs 绕过 API 中的 Service Worker 缓存
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.