簡體   English   中英

使用服務工作線程時,如何在不緩存 angular 中的響應的情況下調用某些 api?

[英]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

繞過 API 中的 Service Worker 緩存

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM