@newaitix

Service Worker at Google Chrome Extention. Очень хочется но колется?

Ранее задавал вопрос Почему не работает кеширование ?
Вопрос касается именно chrome extention.
Я фетчу темплейтеры и они не кешируются.
Тут вспомнил про sw и его могучесть в appCatch.
Взял руки и нажал на кнопки получилось вот.
if ('serviceWorker' in navigator) {
    window.addEventListener('load', function() {
        navigator.serviceWorker.register('/js/sw.js').then(function(registration) {
            console.log('ServiceWorker registration successful with scope: ', registration.scope);
        }).catch(function(err) {
            console.log('ServiceWorker registration failed: ', err);
        });
    });
}

sw.js
var CACHE_NAME = 'my-site-cache-v1';
var urlsToCache = [
	'/html/templater/popUpId.tpl',
	'/html/templater/bodyId.tpl',
	'/html/templater/topNavLog.tpl',
	'/html/templater/topNav.tpl',
	'/html/templater/bodyFailedAuth.tpl',
	'/html/templater/registration.tpl',
	'/html/templater/login.tpl',
	'/html/templater/syncToServ.tpl',
	'/html/templater/syncToPc.tpl',
	'/html/templater/emptySearch.tpl',
	'/html/templater/updateButton.tpl',
	'/html/templater/notification.tpl'
];
self.addEventListener('install', function(event) {
  event.waitUntil(
    caches.open(CACHE_NAME)
      .then(function(cache) {
        return cache.addAll(urlsToCache);
      })
  );
});

Ран.
Лук ин консол а там зис.
ServiceWorker registration successful with scope
И затем
Uncaught (in promise) TypeError: Add/AddAll does not support schemes other than "http" or "https"


Можно ли как то юзать sw в православном chrome-extension:// а не вот в этом вашем http ?
Есть ли обходные пути может кто то сталкивался ? Фетсчить не с локал а с удаленки ? Не очень хорошая идея так как претендую на ачивку "Офлайн-приложение".
  • Вопрос задан
  • 447 просмотров
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы