服务工作者和客户端请求 'Cache-control':'no-cache'

service worker and client requests 'Cache-control': 'no-cache'

假设客户这样做

fetch('example.json', {
    headers: {
      'Accept': 'application/json',
      'Accept-Encoding': 'gzip',
      'Cache-control': 'no-cache'
    },
    method: 'GET'
  }).then()

服务器工作人员执行此操作

self.addEventListener('fetch', (event:any) => {
  let request = event.request
  if (request.method !== 'GET') return
  event.respondWith( caches.match(request)
    .then( cachedResponse => {
      if (cachedResponse) return cachedResponse
      return caches.open(RUNTIME)
        .then(cache => fetch(request)
            .then(response => cache.put(request, response.clone())
                .then(() => response) ))  
  }))
})

我可以假设 caches.match(request) 会计算出 'Cache-control': 'no-cache' 并且不管 service worker 缓存中存储了什么都可以退出吗?

随时纠正我,但在谷歌搜索更多后我发现了这个

https://bugs.chromium.org/p/chromium/issues/detail?id=451664#

当我测试 console.log('SW :', request.headers.get('Cache-control')) 时,headers 似乎被剥离了。

我慢慢明白为什么一些浏览器供应商对服务工作者犹豫不决,这使得整个缓存不直观,而浏览器缓存一开始就不直观。