4 ms·
It is not actually about cache busting. I generate unique filenames for all my JS files and other assets when they update, but the client browser gets to know a
by crookie 9y ago
It is not actually about cache busting. I generate unique filenames for all my JS files and other assets when they update, but the client browser gets to know about them when they download index file, untill then they dont need anything else. So, there are some users who do not refresh browser ever and keep on using the same tab always. I want them to always use the latest index file and thus the latest code. Is there a way to do it just using cache ?
- janesconference 9y agoIf you really want to do it: 1) Store the result of Date.now() somewhere when the app starts 2) Have an interval to check the difference between Date.now() and the timestamp you stored in 1) 3) If the difference is over a certain threshold, force a page reload (or schedule a page reload for when the user is in a "safe" state) Or you could probably poll an endpoint / listen to a websocket and trigger the reloading by flipping a switch or sending a message. It won't be a client-only solution, though.
- crookie 9y agoThanks for the reply, I appreciate it . Will update with what approach i took. I am most probably going to use the webpack hash to do the check .
- janesconference 9y ago(In reality, you should ask yourself why your users are behaving like that: don't they shut down their computer ever? Don't they like updates? That's pretty odd behaviour)
- crookie 9y agoWe are building a new product , and every time we release a new feature , our sales team call up and inform them about the change. Some of them do not refresh their screen and so changes are not visible to them , at that time our sales rep have to ask them to refresh it. It kind of give a bad feeling to the user and so we wanted to do something about it.
- jivings 9y agoIs it that odd? How often do you close the tab containing your email client for example? I literally only ever close mine by accident, and there are a lot of environments in which machines are rarely rebooted.
- crookie 9y agoWell, it's not that odd, but refreshing the app after doing some check using API's is the only way ?