How can I push changes to users when their service worker pulls from a cache and doesn't look for live updates if it finds something in the cache?
up vote
0
down vote
favorite
I think I may have screwed something up. I was trying to get my website working offline by using Service Workers. It lead to issues, so now I have commented out that code and am holding off on getting it to work offline.
However, I just visited the live site on my other laptop, which I haven't done for a while, and it gave me an old version of the website, not the up to date version. The reason why it is giving me an old version is because the service worker is pulling from the cache, and doesn't look for live updates if it finds something in the cache:
self.addEventListener('fetch', function(event)
event.respondWith(
caches.match(event.request).then(function (response)
if (response)
return response;
return fetch(event.request);
).catch(function ()
console.error('Error trying to match event request to cache.');
)
);
);
My question is, for people with that version of the service worker and who have stuff cached, how do I get them to see the live version of the site. I don't see how it would be possible. Whatever changes I deploy, they wouldn't even receive because they are just getting an old cached version. I think I'd need to alert them somehow that they need to go into the dev tools and delete the service worker they have installed and/or cache, but I don't see how I'd be able to inform them of this, because they aren't getting any updates.
javascript service-worker
add a comment |
up vote
0
down vote
favorite
I think I may have screwed something up. I was trying to get my website working offline by using Service Workers. It lead to issues, so now I have commented out that code and am holding off on getting it to work offline.
However, I just visited the live site on my other laptop, which I haven't done for a while, and it gave me an old version of the website, not the up to date version. The reason why it is giving me an old version is because the service worker is pulling from the cache, and doesn't look for live updates if it finds something in the cache:
self.addEventListener('fetch', function(event)
event.respondWith(
caches.match(event.request).then(function (response)
if (response)
return response;
return fetch(event.request);
).catch(function ()
console.error('Error trying to match event request to cache.');
)
);
);
My question is, for people with that version of the service worker and who have stuff cached, how do I get them to see the live version of the site. I don't see how it would be possible. Whatever changes I deploy, they wouldn't even receive because they are just getting an old cached version. I think I'd need to alert them somehow that they need to go into the dev tools and delete the service worker they have installed and/or cache, but I don't see how I'd be able to inform them of this, because they aren't getting any updates.
javascript service-worker
how about adding null content service worker with new version identifier? Zero out files to cache. Obviously you will have to keepself.addEventListener('activate', function (event) {...
function.
– zipzit
2 days ago
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I think I may have screwed something up. I was trying to get my website working offline by using Service Workers. It lead to issues, so now I have commented out that code and am holding off on getting it to work offline.
However, I just visited the live site on my other laptop, which I haven't done for a while, and it gave me an old version of the website, not the up to date version. The reason why it is giving me an old version is because the service worker is pulling from the cache, and doesn't look for live updates if it finds something in the cache:
self.addEventListener('fetch', function(event)
event.respondWith(
caches.match(event.request).then(function (response)
if (response)
return response;
return fetch(event.request);
).catch(function ()
console.error('Error trying to match event request to cache.');
)
);
);
My question is, for people with that version of the service worker and who have stuff cached, how do I get them to see the live version of the site. I don't see how it would be possible. Whatever changes I deploy, they wouldn't even receive because they are just getting an old cached version. I think I'd need to alert them somehow that they need to go into the dev tools and delete the service worker they have installed and/or cache, but I don't see how I'd be able to inform them of this, because they aren't getting any updates.
javascript service-worker
I think I may have screwed something up. I was trying to get my website working offline by using Service Workers. It lead to issues, so now I have commented out that code and am holding off on getting it to work offline.
However, I just visited the live site on my other laptop, which I haven't done for a while, and it gave me an old version of the website, not the up to date version. The reason why it is giving me an old version is because the service worker is pulling from the cache, and doesn't look for live updates if it finds something in the cache:
self.addEventListener('fetch', function(event)
event.respondWith(
caches.match(event.request).then(function (response)
if (response)
return response;
return fetch(event.request);
).catch(function ()
console.error('Error trying to match event request to cache.');
)
);
);
My question is, for people with that version of the service worker and who have stuff cached, how do I get them to see the live version of the site. I don't see how it would be possible. Whatever changes I deploy, they wouldn't even receive because they are just getting an old cached version. I think I'd need to alert them somehow that they need to go into the dev tools and delete the service worker they have installed and/or cache, but I don't see how I'd be able to inform them of this, because they aren't getting any updates.
javascript service-worker
javascript service-worker
asked Nov 11 at 1:22
Adam Zerner
4,75584287
4,75584287
how about adding null content service worker with new version identifier? Zero out files to cache. Obviously you will have to keepself.addEventListener('activate', function (event) {...
function.
– zipzit
2 days ago
add a comment |
how about adding null content service worker with new version identifier? Zero out files to cache. Obviously you will have to keepself.addEventListener('activate', function (event) {...
function.
– zipzit
2 days ago
how about adding null content service worker with new version identifier? Zero out files to cache. Obviously you will have to keep
self.addEventListener('activate', function (event) {...
function.– zipzit
2 days ago
how about adding null content service worker with new version identifier? Zero out files to cache. Obviously you will have to keep
self.addEventListener('activate', function (event) {...
function.– zipzit
2 days ago
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53245033%2fhow-can-i-push-changes-to-users-when-their-service-worker-pulls-from-a-cache-and%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
how about adding null content service worker with new version identifier? Zero out files to cache. Obviously you will have to keep
self.addEventListener('activate', function (event) {...
function.– zipzit
2 days ago