Platinum-sw In Polymer Starter Kit-浏览器缓存/本地存储中没有任何内容

时间:2016-05-10 21:30:31

标签: polymer polymer-1.0

使用聚合物入门套件,我遇到了让platinum-sw-registerplatinum-sw-cache正常工作的问题。当我在资源下查看开发工具时,我看不到本地存储,缓存等的关键值。

我做了我应该做的一切....我取消注释了elements.html中的html导入,使用了index.html中的代码(减去烤面包机通知),确保gulp默认任务包含缓存配置。

以下是dist/cache-config.json

{"cacheId":"wedding","disabled":false,"precache":["index.html","./","bower_components/webcomponentsjs/webcomponents-lite.min.js","elements/elements.html","scripts/app.js","styles/app-theme.html","styles/main.css","styles/shared-styles.html"],"precacheFingerprint":"c546b3ce132d015b719d026e646c1"}

这是index.html:

    <platinum-sw-register auto-register
                          clients-claim
                          skip-waiting
                          base-uri="bower_components/platinum-sw/bootstrap">
      <platinum-sw-cache default-cache-strategy="fastest"
                         cache-config-file="cache-config.json">
      </platinum-sw-cache>
    </platinum-sw-register>
  </template>

这是我的elements.html:

<link rel="import" href="../bower_components/platinum-sw/platinum-sw-cache.html">
<link rel="import" href="../bower_components/platinum-sw/platinum-sw-register.html">

1 个答案:

答案 0 :(得分:0)

问题是这只适用于https而不适用于非https。为了解决问题,我使用了on-service-worker-error="displayInstalledToastError",其中我看到"SecurityError: Only secure origins are allowed (see: https://www.chromium.org/Home/chromium-security/prefer-secure-origins-for-powerful-new-features)."