Skip to content

wjessop/asset-format

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

This plugin has been rendered redundant by fingerprinting in Rails 3, use that instead.

Asset-Format plugin

Install this plugin to force the asset_id to become part of the path to the asset rather than appended to the end with a question mark, so for example:

http://assets1.yourassethost.com/javascripts/prototype.js?1234263214

becomes:

http://assets1.yourassethost.com/javascripts/1234263214/prototype.js

and:

/javascripts/prototype.js?1234263214

becomes:

/javascripts/1234263214/prototype.js

You then need to add a rewrite on which ever server hosts your assets to rewrite the URL including the asset id back to the original asset, eg. /javascripts/1234263214/prototype.js -> /javascripts/prototype.js

Apache example: RewriteEngine on RewriteRule ^(.)/(\d+)/(..\w+)$ $1/$3

Why do this?

"The number after the question mark is a cache code. It’s purpose was to help web browsers notice when the version of an asset (such as your JavaScript) has changed. This way the server, and caching proxies in between, could store your static assets in cache, reducing the load time for your app.

The problem with this approach (which is commonly used in Rails and other popular web frameworks, by the way) is that some proxies on the web are misconfigured to ignore this cache code if the resource you are requesting ends in a “static” resource extension such as .js, .html, etc. The result was that some proxies would keep your old assets cached when you deployed new versions, even if your cache code changed."

-- source

Installation

cd rails_project_base_dir && script/plugin install git://github.com/wjessop/asset-format.git

Copyright (c) 2009 Will Jessop (http://willj.net), released under the MIT license

About

Plugin to add an asset id into the path of the asset instead of appending it to the end with a question mark

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages