1 В избранное 0 Ответвления 0

OSCHINA-MIRROR/xurime-toml-to-go

Присоединиться к Gitlife
Откройте для себя и примите участие в публичных проектах с открытым исходным кодом с участием более 10 миллионов разработчиков. Приватные репозитории также полностью бесплатны :)
Присоединиться бесплатно
Клонировать/Скачать
sw.js 1.4 КБ
Копировать Редактировать Web IDE Исходные данные Просмотреть построчно История
peng Отправлено 12.03.2019 05:45 8d4c402
var CACHE = "v1.1"
var filesToCache = [
'./',
'./resources/js/jquery.min.js',
'./resources/js/highlight.min.js',
'./resources/js/json-to-go.js',
'./resources/js/common.js',
'./resources/js/gofmt.js',
'./resources/css/tomorrow.highlight.css',
'./resources/css/common.css',
'./resources/images/toml-to-go.png'
]
self.addEventListener('install', function (evt) {
console.log('Attempting service worker installation.');
// Wait until promise resolves
evt.waitUntil(precache());
});
// On fetch, return from cache
self.addEventListener('fetch', function (evt) {
evt.respondWith(serve(evt.request));
});
// Opens cache and loads filesToCache into cache for using them in future
function precache() {
return caches
.open(CACHE)
.then(function (cache) {
return cache.addAll(filesToCache);
});
}
// When a resource is requested first serve from service worker and if service
// worker hasn't cached that request, then fetch that resource and then serve it
// This strategy is cache first.
function serve(request) {
return caches
.open(CACHE)
.then(function (cache) {
return cache
.match(request)
.then(function (matching) {
return matching || fetch(request);
})
.catch(console.error);
});
}

Опубликовать ( 0 )

Вы можете оставить комментарий после Вход в систему

1
https://api.gitlife.ru/oschina-mirror/xurime-toml-to-go.git
git@api.gitlife.ru:oschina-mirror/xurime-toml-to-go.git
oschina-mirror
xurime-toml-to-go
xurime-toml-to-go
master