【问题标题】:Why my file is not cached via the Service Broker?为什么我的文件没有通过 Service Broker 缓存?
【发布时间】:2020-12-05 11:48:32
【问题描述】:

我发现了一个导致 Service Broker 缓存操作失败的文件。或者更准确地说,让它什么都不缓存。 我有一个包含要缓存的文件的数组。

当这个 'view/viewListAttentes.php' 被评论时,这个过程就起作用了,文件被添加到缓存存储中。 但是当它不是时,“site-static-v9”被创建但为空。这个文件和其他文件一样在文件夹中。

那么你知道文件的什么问题会导致这种情况吗?

const staticCacheName = 'site-static-v9';
const assets = [
'/index.php',
'/css/global.css',
'/js/app.js',
'/js/rech.js',
'/js/rechFormFilm.js',
'/js/button.js',
'/modele/modele.php',
'/param/param.ini',
'/view/viewAjout.php',
'/view/viewFooter.php',
'/view/viewHeader.php',
// '/view/viewListAttentes.php', When commented it's working, else the cache is empty
'/view/viewMenuEnTete.php',
];

// installation of the Service Worker
self.addEventListener('install', e => {
    console.log('SW installé', e);
    e.waitUntil(
        caches.open(staticCacheName)
            .then(cache => {
                console.log('-------On cache en static les éléments----------');
                return cache.addAll(assets)
                            .then(e => {
                                console.log(e);
                            })
                            .catch(e => {
                                console.log("erreur addAll", e.message);
                            });
            })
            .catch(err => {
                console.log("erreur open cache", err.message);
            })
    );
});

【问题讨论】:

    标签: progressive-web-apps browser-cache service-broker


    【解决方案1】:

    我真的不知道为什么,但似乎这个文件中的一个标签使它无法缓存....奇怪,因为我有很多 .php 文件,这些标签使用 addAll() 方法缓存。

    为了使它正常工作,我将这个 php 标签移到 index.php 中。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-10-13
      • 2016-10-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-11-14
      相关资源
      最近更新 更多