When configuring ContentVersionStrategy we are experiencing a problem when a resource referenced in a css file is modified (url with md5 hash changed) but the css file itself remains exactly the same (same md5 hash). We are not getting the last version as the application is rewritting the resource with the same hash (i.e: style-8736f7fc00b943645acfcde4d1456233.css) but the actual content is different (different hashes in the rewritten urls inside de css file).

Are we doing something wrong? Is there a way to compute de md5 hash (ContentVersionStrategy) after content of the css has been transformed by the CssLinkResourceTransformer?

Comment From: didiez

Here's a simple application to reproduce the issue https://github.com/didiez/spring-resources-versioning-issue

Comment From: bclozel

I think that's a limitation of the current design. When resolving paths with the the resource chain, the ContentVersionStrategy is only looking at the actual resource content and not involving the resource transformer chain. Any transformer impacting the content of the resource is not changing the content and the hash of the resource remains the same.

We should take a look at this limitation and see if we can fix this without breaking existing contracts.

As a side note, HTTP caching config and the resolver chain strategies should be enabled in production-specific profiles and left out of the dev profile. I know this is probably done on purpose in this sample, I just wanted to point that out in case this issue is bothering you while working on your app.

Thanks!

Comment From: didiez

Thanks for the quick response :)

Yes, http caching is enabled by default to simplify the sample. We have no issues while developing as these properties are only defined for production. Thanks for pointing it out, though.

Comment From: rstoyanchev

From recollection I think we discussed this at some point. The option I recall is to configure the resource chain and provide a Cache instance to use. This instance can then be used to invalidate the cache. It's a crude mechanism but one option at least.

Comment From: ealouie

Has there been any more consideration of a fix for this issue? My coworkers and I ran into this issue with one of our css files we were caching that is importing from fontawesome.