How can I force the browser to refresh css files?

Hi,

I’m using Vaadin 6 with a custom theme.

The problem is that when I do changes to our css files browsers don’t know that the file was changed and they still use old cached css file.

One solution for this could be to rename our theme for each version, but it has some drawbacks (e.g.with version control repository)

It would be great if we can tell Vaadin to use something like this when building HTMLs:

/mytheme/styles.css?v=currentVersion

And be able to change “currentVersion” any time. Here’s a detailed description of the
idea

Is there a way to do that? Or any other way to force css refresh?

Thanks

Gabriel

in chrome I use some addon called “css-reloader” for this…

Actually I was looking for a way to force a refresh of all users’ browsers, so they see the new css, not my machines browser.

The use of a query string like that hurts/eliminates much of beneficial caching (see e.g.
this article
). For a single small loader file (such as the widgetset loader bootstrap JavaScript) it can be ok, but it might be a bad idea to use it for a large number of larger files.

Unfortunately, truly forcing CSS refresh is hard, in part also because e.g. Chrome sometimes seems to ignore the information the server has given it about what caching it is allowed to do (at least for stylesheets) and caches CSS more aggressively.

Hi Henri,

Thank you for your response. I read that article and it recommends changing file’s name instead of using query string to version files, that will certainly force any browser to (re)load changed files. And that’s ok with me, but I couldn’t find a way to do that with Vaadin. Since I can’t tell Vaadin to use other files than “styles.css”. Is there a way to do that? I mean to tell Vaadin to use another file name for it’s main css?

The only workaround that I found was to change the directory, but of course the drawback of that is that the browser will reload everything and not just a few files that changed.

Thanks,

Gabriel

PD: I’m sorry for the delay in the response, I’m not getting email notifications from this forum.

Any news? New ideas?

Experiencing the same problem, any suggestion?

Unfortunately, truly forcing CSS refresh is hard, [MyFedLoan]
(https://myfedloan.us/) in part also because e.g. Chrome sometimes seems to ignore the information the server has given it about what caching it is allowed to do (at least for stylesheets) and caches CSS more aggressively.