-
-
Notifications
You must be signed in to change notification settings - Fork 87
Updating WebCLient does not force the browser to clear old cache #292
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
It's actually a bit more complex than that. On the one hand, every new release includes new assets with a unique hash calculated at build time. That should, in theory, prevent cache issues when a new version is released. However, that depends on the index.html to not be cached, as having an outdated version pointing to the old assets will make the browser continue using the old ones. Usually you solve that by disabling any caching on html files. These kind of SPAs only have one, so it's usually ok. I think this needs to be adjusted on app.shlink.io But that's not it. The app also includes a service worker, which introduces yet another caching layer and extra complexity.
The service worker loads data locally, and reloads it offline, so you always get an outdated version on first load. It's a trade-off. So, long story short, all that combined makes it a bit unpredictable. I have tried to solve caching issues in the past, but it's not there yet. I'll try to spend a bit more time trying to get it smooth. |
Hey @Martinh0 I have done some changes that should mitigate this issue. One the one hand, I have removed the service worker completely. It used to be the default for react apps, but it is not anymore. I was still dragging it from the day I created the project a couple of years ago. That should solve the first issue you were describing, in which after updating, refreshing was taking you back to previous version. On the other hand, I have added proper HTTP cache to the nginx inside the official docker image. This config does the next:
This config will apply either if you use the official docker image, or app.shlink.io (since the latter also uses the official docker image). If you use other mechanisms to serve the web client, you will have to take care of setting up this caching config. |
This happens for every version.
I updated to the new version (2.5.0 => 2.5.1) and when I open it in the Browser it first shows v2.5.1, but hitting normal reload will call the cached version offline and shows 2.5.0.
This should be prevented by forcing the browser to update its cache or to overwrite it with the newer version. But TTL of the Cache should not get touched as this woulod result in not having it offline available for long time.
The text was updated successfully, but these errors were encountered: