Skip to content

kristopher/asset-version

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AssetVersion

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.

Example

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>

Install

As a Rails plugin.

./scpript/plugin install git://github.com/kristopher/asset-version.git
Homepage

github.com/kristopher/asset_version

License

Copyright © 2008 Kristopher Chambers <[email protected]>, released under the MIT license.

About

Amazingly easy versioning for cached assets.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages