2

Instead of asking all users to delete their cache when an update is pushed, is there a script I can add to my app so that when the site is loaded it deletes the existing cache for the site?

I could remove the script when the app is complete but for development and testing purposes I deploy (or serve locally) multiple times a day, its a pain to have to delete my cache every time.

An even bigger pain is trying to get others to delete cache when I tell them the site has been updated and I need feedback.

Thanks

EDIT: After much searching I think this How to remove a service worker registered in previous deploy from users' browsers with the newly deployed version of site (Firebase)? is similar to what the problem is, but the answers are not specific. It looks like the issue might be with a service worker but I am unsure how to implement a fix.

noxasaxon
  • 2,263
  • 1
  • 8
  • 14
  • 1
    I'm having a very hard time understanding what you're talking about here, and how it relates to Firestore, as you've tagged the question. – Doug Stevenson Jun 04 '18 at 02:20
  • my site uses the cloud firestore database. – noxasaxon Jun 04 '18 at 05:54
  • So, what are you deploying? What do you mean by "site cache"? What's the script that you've written? – Doug Stevenson Jun 04 '18 at 06:04
  • Im asking if there is a way to see the updated page hosted on firestore without wiping the cache; If not, is it possible to make a script to wipe the browsers site cache when you first connect to the site. – noxasaxon Jun 04 '18 at 06:17
  • I think this question is more related to firebase hosting, and not so much firestore if I understand? – DauleDK Jun 04 '18 at 06:19
  • Firestore doesn't host "pages". It stores "documents". I'm still having a hard time understanding what it is you're observing and how it relates to Firestore. – Doug Stevenson Jun 04 '18 at 06:19
  • 1
    I tagged firestore because thats the database im using for the site hosted on firebase, if thats wrong I can delete the tag. I have a react app that im deploying to firebase via the CLI. When i make an edit to the app and deploy (or serve locally) then visit the site, the changes won't be seen because the browser is using the cached version of the site. To fix this you Ctrl+shift+i and hit "Clear Site Data". My question is that this is tedious for my customer to do, so is there a script or command i can add to my react app or html page that will clear the site cache when the browser connects. – noxasaxon Jun 04 '18 at 06:26
  • I actually think your question is good. Strictly speaking it probably has nothing to do with reactjs as well. Maybe you can rephrase the question to something like this: When using firebase-hosting and publishing a static web-app, is it somehow possible for users that have already loaded the application to get the newest version, without them having to hard browser-reload? – DauleDK Jun 04 '18 at 06:39
  • Possible duplicate of [Firebase deploy not updating JS file](https://stackoverflow.com/questions/34192901/firebase-deploy-not-updating-js-file) – DauleDK Jun 04 '18 at 06:46
  • @DauleDK I just found this [How to remove a service worker registered in previous deploy from users' browsers with the newly deployed version of site (Firebase)?](https://stackoverflow.com/questions/48157823/how-to-remove-a-service-worker-registered-in-previous-deploy-from-users-browser?rq=1) which seems similar but I cant tell how to implement it – noxasaxon Jun 04 '18 at 06:51
  • Hmm, I will try to look at it. I think I would probably try to solve the problem, by listening to a firestore node with the version, and when this version number is changed, hard reload? – DauleDK Jun 04 '18 at 09:12
  • You could maybe look at something like this: https://stackoverflow.com/questions/2099201/javascript-hard-refresh-of-current-page – DauleDK Jun 04 '18 at 09:19
  • 1
    One way to solve your problem is to use html-webpack-plugin (or webpack's built-in hashing ability), see https://stackoverflow.com/questions/36481216/caching-issue-with-web-application-developed-using-reactjs-webpack. By default, Javascript bundle file and css keep the same file names when you re-build, hence the caching done by the browser. The problem is not really related to Firebase Hosting, you would encounter it with any other hosting platform. And it is also classic with SPA frameworks, for example Vue.js. – Renaud Tarnec Jun 04 '18 at 09:35

0 Answers0