Has the Rails asset versioning let you down? AssetVersion ensures your users NEVER load out of date assets. Cached assets include this version in the file name so a version change guarantees a new request from the client.
This works only for javascript and stylesheets referenced with the :cache option.
If you’re using capistrano, AssetVersion will automatically grab version information from your SCM on deploy. Otherwise you can manually set the AssetVersion in your environment.rb or an initializer like so:
AssetVersion.version = 'version_one'
Now when you use javascript_include_tag or stylesheet_link_tag with the :cache option, it will automatically include the version in the filename.
javascript_include_tag('application', 'extra', :cache => 'all') #=> <script type="text/javascript" src="/javascripts/all_version_one?123456789"></script>
If necessary, you can override the version information on a per call basis by supplying a :version option.
stylesheet_link_tag('application', 'blueprint', :cache => 'all', :version => 'version_two') #=> <script type="text/javascript" src="/stylesheets/all_version_two?123456789"></script>
As a Rails plugin.
./scpript/plugin install git://github.com/kristopher/asset-version.git
- Homepage
- License
-
Copyright © 2008 Kristopher Chambers <kristopher.chambers@gmail.com>, released under the MIT license.