Reputation: 782
My service worker is really simple; just a method for caching fonts, JS, and a few other items to accelerate page performance and reduce data transfer.
However, when live (example) navigating to a second page then using the browser's back button displays the OFFLINE page rather than TRYing first or using the natural browser cache.
Relevant part of SW:
// Clear old caches when activated
self.addEventListener('activate', function(e) {
e.waitUntil(
caches.keys().then(function(keyList) {
return Promise.all(keyList.map(function(key) {
if (key !== cacheName) {
console.log('[ServiceWorker] Removing old cache', key);
return caches.delete(key);
}
}));
})
);
return self.clients.claim();
});
self.addEventListener('fetch', function(event) {
event.respondWith(
// Try the cache
caches.match(event.request).then(function(response) {
// Fall back to network
return response || fetch(event.request);
}).catch(function() {
// If both fail, show a generic fallback:
return caches.match('/offline.htm');
// However, in reality you'd have many different
// fallbacks, depending on URL & headers.
// Eg, a fallback silhouette image for avatars.
})
);
});
This seems more likely (or possibly isolated to) Firefox (current version 59.0.2).
Upvotes: 0
Views: 398
Reputation: 146510
So Installed FF developer version
And it works fine in FF60
FF60
The issue is with FF59.0 it seems
FF59
So most probably a issue that will be fixed with next update
Upvotes: 2