2021-11-08 08:32:37 +00:00
|
|
|
var CACHE_NAME = 'tytd-cache-v1';
|
|
|
|
var urlsToCache = [
|
|
|
|
'./',
|
|
|
|
'./css/styles.css',
|
|
|
|
'./css/bootstrap.min.css',
|
|
|
|
'./js/bootstrap.min.js',
|
|
|
|
'./js/main.js',
|
|
|
|
'./js/new_main.js',
|
|
|
|
'./js/search.js',
|
|
|
|
'./js/spa.js',
|
|
|
|
'./js/jquery.js',
|
|
|
|
'./search.html',
|
|
|
|
'./upload.html',
|
2022-01-03 20:33:20 +00:00
|
|
|
'./legacy.html',
|
|
|
|
|
2021-11-08 08:32:37 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
self.addEventListener('install', function(event) {
|
|
|
|
// Perform install steps
|
|
|
|
event.waitUntil(
|
|
|
|
caches.open(CACHE_NAME)
|
|
|
|
.then(function(cache) {
|
|
|
|
console.log('Opened cache');
|
|
|
|
return cache.addAll(urlsToCache.map(url => new Request(url,{credentials: 'same-origin'})));
|
|
|
|
})
|
|
|
|
);
|
|
|
|
});
|
|
|
|
self.addEventListener('fetch',function(event) {
|
|
|
|
event.respondWith(
|
2022-01-03 20:33:20 +00:00
|
|
|
|
2021-11-08 08:32:37 +00:00
|
|
|
caches.match(event.request)
|
|
|
|
.then(function(response) {
|
|
|
|
// Cache hit - return response
|
|
|
|
|
|
|
|
if (response) {
|
|
|
|
return response;
|
|
|
|
}
|
|
|
|
return fetch(event.request);
|
|
|
|
}
|
|
|
|
)
|
|
|
|
);
|
|
|
|
});
|