pwa workbox没有在缓存中找到响应

时间:2018-06-01 16:24:16

标签: vaadin workbox pwa

我已配置以下工作箱路由来缓存从新闻服务newsapi.org获取的所有文章。我可以看到文章存储在缓存中,但是当我在chrome中脱机模式时,然后尝试访问缓存的url,工作箱告诉我在缓存中没有找到响应(即使我可以在那里看到它)。我在这里错过了什么? 原始代码基于Vaadin Progressive Web App tutorial

workbox.routing.registerRoute(
  // Cache news articles
  new RegExp('^https?:\/\/newsapi.org/(.*)'), args => {
  return workbox.strategies.networkFirst({
    cacheName: 'news-cache',
    plugins: [
      new workbox.expiration.Plugin({
        maxEntries: 20,
        maxAgeSeconds: 7 * 24 * 60 * 60,
      })
    ],
  }).handle(args).then(response => {
    if (!response) {
      return caches.match('./fallback.json');
    }
    return response;
  });
});

Response not found in cache

0 个答案:

没有答案
相关问题