Bjo53 commited on
Commit
f42d41a
·
verified ·
1 Parent(s): db4aacb

Upload static/sw.js with huggingface_hub

Browse files
Files changed (1) hide show
  1. static/sw.js +35 -0
static/sw.js ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ const CACHE_NAME = 'terminal-v1';
2
+ const urlsToCache = [
3
+ '/',
4
+ '/static/index.html',
5
+ '/static/manifest.json'
6
+ ];
7
+
8
+ self.addEventListener('install', event => {
9
+ event.waitUntil(
10
+ caches.open(CACHE_NAME)
11
+ .then(cache => cache.addAll(urlsToCache))
12
+ );
13
+ self.skipWaiting();
14
+ });
15
+
16
+ self.addEventListener('fetch', event => {
17
+ event.respondWith(
18
+ caches.match(event.request)
19
+ .then(response => {
20
+ if (response) return response;
21
+ return fetch(event.request);
22
+ })
23
+ );
24
+ });
25
+
26
+ self.addEventListener('activate', event => {
27
+ event.waitUntil(
28
+ caches.keys().then(cacheNames => {
29
+ return Promise.all(
30
+ cacheNames.filter(name => name !== CACHE_NAME)
31
+ .map(name => caches.delete(name))
32
+ );
33
+ })
34
+ );
35
+ });