![](/img/trans.png)
[英]node.js - how Caching handlebars.js using service worker
[英]How to call certain apis without caching a response in angular when using service worker?
我附上了 2 張圖片。 第一張圖片是我第一次加載注冊 service-worker 的網站。 有2個箭頭,顯示302 found,設置session信息的cookies。
這是第二次(參考下圖),在我退出並使用谷歌再次登錄后,我得到下圖作為響應。 你可以從圖像中看到沒有設置 cookies,它實際上來自 service worker。
這是我的 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)"
]
}
}
]
}
所以 service worker 正在緩存 api 響應並從緩存中返回。 繞過某些 api 的 service worker。 在查詢參數中添加鹽或使用ngsw-bypass
。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.