-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
serviceWorker serving stale frontend assets #9044
Comments
One solution I have been using in the past is write the js/css build timestamp into HTML (like |
What about having some mechanism to override
And change:
into
Then we can run Gitea like:
Sorry if I'm speaking nonsense; I have only some superficial understanding of modern day UI library composition. |
I don't think that would work. A SW will not check for a update to itself unless it is being told do (or 24h have passed). I think the only leverage we have is a (inline) script loaded from HTML that will unregister the worker if gitea is started in development mode (maybe via a flag or env var). The next time gitea is started in "production" mode, it would then register again and do regular caching. Do we have any suitable flags/vars that could be used? |
This will be very useful setting for anyone doing frontend work. Fixes: go-gitea#9044
* Add USE_SERVICE_WORKER setting This will be very useful setting for anyone doing frontend work. Fixes: #9044 * prevent potential syntax error on old browsers
The serviceWorker script we use to cache frontend assets is rather hindering during frontend development as it often serves stale content where one does not see JS changes reflected on the running application.
To my understanding, the service worker script is at most fetched every 24h by a browser, but I'm not sure if that is actually the root issue because even if I force-reload (which should invalidate the SW cache), I often see stale assets. The only reliable way that get fresh content I found is to unregister the SW manually and force-reload the page.
For development needs, we can probably set up a separate development server where SW is always unregistered, but I wonder if we can improve the invalidation mechanism of the serviceWorker itself as users might see JS that's up to 24 hours old.
The text was updated successfully, but these errors were encountered: