How to implement cachebust within CSS - Mendix Forum

How to implement cachebust within CSS

0

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

asked
2 answers
1

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:

 

https://stackoverflow.com/questions/32840388/cache-busting-images-which-are-linked-inside-sass-files

answered
0

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.

 

https://medium.com/@jasonteunissen/how-do-i-start-styling-in-mendix-gulp-sass-6b37ddaf8de6

answered