Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Chrome's currently missing some useful cache methods,
- // this polyfill adds them.
- importScripts('serviceworker-cache-polyfill.js');
- // Here comes the install event!
- // This only happens once, when the browser sees this
- // version of the ServiceWorker for the first time.
- self.addEventListener('install', function(event) {
- // We pass a promise to event.waitUntil to signal how
- // long install takes, and if it failed
- event.waitUntil(
- // We open a cache…
- caches.open('simple-sw-v1').then(function(cache) {
- // And add resources to it
- return cache.addAll([
- './',
- 'style.css',
- 'logging.js'
- ]);
- })
- );
- });
- // The fetch event happens for the page request with the
- // ServiceWorker's scope, and any request made within that
- // page
- self.addEventListener('fetch', function(event) {
- // Calling event.respondWith means we're in charge
- // of providing the response. We pass in a promise
- // that resolves with a response object
- event.respondWith(
- // First we look for something in the caches that
- // matches the request
- caches.match(event.request).then(function(response) {
- // If we get something, we return it, otherwise
- // it's null, and we'll pass the request to
- // fetch, which will use the network.
- return response || fetch(event.request);
- })
- );
- });
- {
- "short_name": "Ferie Med Mening",
- "name": "Ferie Med Mening",
- "icons": [
- {
- "src": "https://feriemedmening.xyz/wp-content/uploads/2018/01/ikon-1.png",
- "type": "image/png",
- "sizes": "48x48"
- },
- {
- "src": "https://feriemedmening.xyz/wp-content/uploads/2018/01/ikon-1.png",
- "type": "image/png",
- "sizes": "96x96"
- },
- {
- "src": "https://feriemedmening.xyz/wp-content/uploads/2018/01/ikon-1.png",
- "type": "image/png",
- "sizes": "192x192"
- }
- ],
- "start_url": "https://feriemedmening.xyz/"
- "score_url": "https://feriemedmening.xyz/"
- "theme_color": "#2ABB9C"
- }
Add Comment
Please, Sign In to add comment