I have a Rails 4.2.4 (Ruby 2.2.2) application and I am serving static assets via Cloudfront.
If Cloudfront is serving something you don't want, there are two possibilities:
However, when i change
Rails.application.config.assets.version = '1.0'
to
Rails.application.config.assets.version = '2.0'
(in config/initializers/assets.rb)
and
delete all the assets in public/assets
run "RAILS_ENV=staging bundle exec rake assets:precompile"
the same file names are generated!
The only way i found to invalidate the digested file of application.scss was to add some dummy content in order to provoke a new md5 checksum.
What am i doing wrong?
Shouldn't a new assets.version change the digested file names?
Best Regards and thanx!
To compile your assets locally, run the assets:precompile task locally on your app. Make sure to use the production environment so that the production version of your assets are generated. A public/assets directory will be created. Inside this directory you'll find a manifest.
rake assets:clean removes compiled assets. It is run by cap deploy:assets:clean to remove compiled assets, generally from a remote server.
rails assets:precompile is the task that does the compilation (concatenation, minification, and preprocessing). When the task is run, Rails first looks at the files in the config.assets.precompile array. By default, this array includes application.js and application.css .
As per the comments in the Rails pull request I opened, this is a regression that needs to be fixed: https://github.com/rails/sprockets-rails/issues/240
Update: As sansarp mentions, one of the workarounds listed in that github issue is to use an old version of sprockets:
gem 'sprockets', '< 3.0.0'
Another workaround is to use the asset path as a cache breaker instead:
# config/initializers/assets.rb
Rails.application.config.assets.prefix = "/assets/v1"
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