I’m still struggling with accessing lumo/lumo.css (separate thread)
but another issue I’m having is how to ensure my users get a fresh copy of the styling when we deploy a new version.
How do you guys do it?
- Do nothing and let the browser/user refresh it when they want?
- Configure time-to-live in web server / spring boot?
- Some sort of unique url?
Up until recently, I’ve been in the first camp, but this does some times cause noise, so recently I added our app version to the URL:
public default void loadCss(String css) {
// Append version no to css for cache busting
css = css + "?v=" + SystemProperties.getGitVersion();
UI ui = UI.getCurrent();
boolean loaded = ui.getElement().getProperty(css, false);
if(!loaded) {
ui.getPage().addStyleSheet(css);
ui.getElement().setProperty(css, true);
}
}
I’d prefer to use @StyleSheet, but there I have a static string, so can’t do that, unless I have a placeholder that gets replaced with verison or checksum while building?