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.










share|improve this question





















  • 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














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.










share|improve this question





















  • 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












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.










share|improve this question













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






share|improve this question













share|improve this question











share|improve this question




share|improve this question










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 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















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

















active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













 

draft saved


draft discarded


















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






























active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes















 

draft saved


draft discarded















































 


draft saved


draft discarded














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





















































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







Popular posts from this blog

Top Tejano songwriter Luis Silva dead of heart attack at 64

ReactJS Fetched API data displays live - need Data displayed static

政党