This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Implements stale-while-revalidate | |
| self.addEventListener('fetch', event => { | |
| const cached = caches.match(event.request); | |
| const fetched = fetch(event.request); | |
| const fetchedCopy = fetched.then(resp => resp.clone()); | |
| // Call respondWith() with whatever we get first. | |
| // If the fetch fails (e.g disconnected), wait for the cache. | |
| // If there’s nothing in cache, wait for the fetch. | |
| // If neither yields a response, return a 404. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var util = require('util'); | |
| // nobody cares about warnings so lets make them errors | |
| // keep a reference to the original console methods | |
| var consoleWarn = console.warn; | |
| var consoleError = console.error; | |
| function logToError() { | |
| throw new Error(util.format.apply(this, arguments).replace(/^Error: (?:Warning: )?/, '')); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // | |
| // Regular Expression for URL validation | |
| // | |
| // Author: Diego Perini | |
| // Created: 2010/12/05 | |
| // Updated: 2018/09/12 | |
| // License: MIT | |
| // | |
| // Copyright (c) 2010-2018 Diego Perini (http://www.iport.it) | |
| // |