progressive-web-apps - 为什么我的文件没有通过 Service Broker 缓存?
问题描述
我确定了一个使 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);
})
);
});
解决方案
我真的不知道为什么,但似乎这个文件中的一个标签使它无法缓存....奇怪,因为我有很多 .php 文件,这些标签使用 addAll() 方法缓存。
为了让它工作,我在 index.php 中移动了这个 php 标签。
推荐阅读
- r - 如何在单独的列中计算所有相似的日期
- python - 尝试使用 Python 3.7.2 pip 安装包会导致 TSL/SSL 错误
- loops - KSH:循环通过双引号逗号分隔变量
- php - 在 Laravel 中寻址文件
- python - Pytorch 中位数 - 是错误还是我用错了
- python - 如何在 Python 中向直方图添加特定的 x 刻度线?
- acumatica - Acumatica 报告未显示在 Acumatica 中
- python - 读取具有可变长度字符串的文件时,pandas.read_csv 很慢
- api - 在 DDD 中获取具有所有(或部分)相关实体的对象的最佳方式
- javascript - 更改汉堡图标