How to implement cachebust within CSS - Mendix Forum

How to implement cachebust within CSS


Hi community,

I understand that for each deployment a new number is generated to replace the {{cachebust}} parameter in HTML-files. In the theme-folder one should use this, such that in the deployment folder this is replaced by a specific number.

Now I also want that this mechanism is applied in my CSS-files, such that something like the following will get replaced by that number when deployed:

.bgClass {
  background: url("/images/background.png?{{cachebust}}") no-repeat;

However, this replacement mechanism seems only to work for HTML-files, not for CSS-files.

Does anyone recognise this problem? Any suggestions to do this?

Thanks! Johan

2 answers

I don't think you'll be able to use the Mendix cache bust value in this case, but I do think you can create your own. The answers on this SO article seem like a good idea - essentially a changing value (the current timestamp) every time you compile your SASS into CSS:


So im not an expert on this, but I'd think that you'd do this through your compiling tool.

A lot of ppl use gulp to compile their sass and there must be a way to implement this in your build chain.