Javascript 服务工作者:远程文件不是';不要缓存

Javascript 服务工作者:远程文件不是';不要缓存,javascript,caching,browser-cache,service-worker,progressive-web-apps,Javascript,Caching,Browser Cache,Service Worker,Progressive Web Apps,我正在尝试在我的渐进式web应用程序中缓存静态文件和远程文件 静态文件会被缓存,但远程文件不会 代码如下: self.addEventListener( 'install', e => { e.waitUntil( caches.open( 'offline' ) .then( cache => cache.addAll([ '/', 'https://maxcdn.bootstrapcdn.c

我正在尝试在我的渐进式web应用程序中缓存静态文件和远程文件

静态文件会被缓存,但远程文件不会

代码如下:

self.addEventListener( 'install', e => {
    e.waitUntil(
        caches.open( 'offline' )
        .then( cache => cache.addAll([
            '/',
            'https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css',
            'https://code.jquery.com/jquery-3.2.1.js',
            'scripts/firebase.js',
            'scripts/localForage.js',
            'old-index.html',
            'scripts/main.js',
        ]))
    );
});
提前谢谢

这是更新后的代码

var filesToCache = [
    '.',
    "https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.5.0/css/bootstrap-datepicker.css",
    'https://code.jquery.com/jquery-3.2.1.js',
    'scripts/firebase.js',
    'scripts/localForage.js',
    'cce.html',
    'scripts/main.js',
    'scripts/secondary.js',
    'https://cdn.datatables.net/1.10.15/css/jquery.dataTables.min.css'
];

var staticCacheName = 'pages-cache-v1';

self.addEventListener('install', function(event) {
  console.log('Attempting to install service worker and cache static assets');
  event.waitUntil(
    caches.open(staticCacheName)
    .then(function(cache) {
      return cache.addAll(filesToCache);
    })
  );
});

我猜您使用的格式与本文中的格式不同。下面是来自以下内容的示例代码:


我尝试了示例代码以及文档中的代码,但问题仍然存在。是否还有其他问题,该代码无法正常工作?
self.addEventListener('install', function(e) {
  e.waitUntil(
    caches.open('airhorner').then(function(cache) {
      return cache.addAll([
        'https://paul.kinlan.me/'
      ]);
    })
  );
});