I couldn't find the clear answer to this question in the docs. Many references just say that "changing the version invalidates the assets". Well, then isn't the same done by the fingerprinting mechanism, which generates hash tags based on file contents and names? Does anyone know what exactly config.assets.version
is for?
config.assets.version is an option string that is used in MD5 hash generation. This can be changed to force all files to be recompiled.*
This can be helpful when the asset content hasn't changed, but you want to change the response headers served with the asset, but those headers are cached somewhere like a CDN or user's browser.
Changing your assets version will allow you to regenerate all of your assets with new md5 hashes, allowing you to serve up the same assets to your CDN with new headers.
*From RailsGuides - Configuring Rails Applications
NOTE: As of 20th May 2016, this feature does appear to have been broken for some time https://github.com/rails/sprockets-rails/issues/240. An alternative is to change the value of Rails.application.config.assets.prefix
instead.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With