Some caching fixes

This commit is contained in:
Martin Donnelly 2018-10-18 22:30:06 +01:00
parent 3b6f024dca
commit b306c16424

View File

@ -11,7 +11,7 @@
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
const CACHE_VERSION = { 'version': '0.0.894' }; const CACHE_VERSION = { 'version': '0.0.895' };
const PRECACHE = `jubileeData-${CACHE_VERSION.version}`; const PRECACHE = `jubileeData-${CACHE_VERSION.version}`;
const RUNTIME = 'runtime'; const RUNTIME = 'runtime';
@ -124,23 +124,9 @@ self.addEventListener('fetch', event => {
); );
}*/ }*/
if (event.request.url.startsWith(self.location.origin)) { /*if (event.request.url.startsWith(self.location.origin)) {
console.log('One of our requests..'); console.log('One of our requests..');
/* event.respondWith(
caches.open(RUNTIME).then(function(cache) {
return cache.match(event.request).then(function(response) {
var fetchPromise = fetch(event.request).then(function(networkResponse) {
console.log('Updating cache:', event.request);
cache.put(event.request, networkResponse.clone());
return networkResponse;
});
return response || fetchPromise;
});
})
);*/
event.respondWith( event.respondWith(
caches.open(RUNTIME).then(function(cache) { caches.open(RUNTIME).then(function(cache) {
@ -155,7 +141,7 @@ self.addEventListener('fetch', event => {
}); });
}) })
); );
} }*/
if (event.request.url.startsWith('https://maps.googleapis.com')) { if (event.request.url.startsWith('https://maps.googleapis.com')) {
const url = new URL(event.request.url); const url = new URL(event.request.url);