Skip to content
Newer
Older
100644 56 lines (38 sloc) 1.57 KB
581d22c @grosser update readme
authored Jun 29, 2011
1 Improve Rails Asset Caching with MD5 and virtual folders
3c6dd8e @grosser pimp my readme
authored Jun 24, 2011
2
581d22c @grosser update readme
authored Jun 29, 2011
3 - MD5 only changes on content-change and is identical on all servers
4 - Virtual folders are CDN/proxy/... cacheable and transparent via nginx/apache rewrite rule
3c6dd8e @grosser pimp my readme
authored Jun 24, 2011
5
6 # Results
7
8 /foo/bar.jpg ... will be ...
9
10 # default + simple rewrite rules
11 /asset-v1afd23/foo/bar.jpg # style: folder method: MD5
12
b35e304 @grosser fix for 3.0.8
authored Jun 25, 2011
13 # rails 3.1-ish, but complicated rewrite rules
3c6dd8e @grosser pimp my readme
authored Jun 24, 2011
14 /foo/bar-asset-v1afd23.jpg # style: suffix method: MD5
15
16 # no rewrite rule needed (great for development)
17 /foo/bar.jpg?1afd23 # style: query method: MD5
18
a12e556 @grosser test it
authored Jun 25, 2011
19 # different methods ...
20 /asset-v1308942465/foo/bar.jpg # style: folder method: mtime
21 /asset-vxxx/foo/bar.jpg # style: folder method: ENV['RAILS_ASSET_ID'] = 'xxx'
22
3c6dd8e @grosser pimp my readme
authored Jun 24, 2011
23 # configure
24 VirtualAssetPath.style = :folder # default
25 VirtualAssetPath.style = :MD5 # default
16a9900 @grosser initial
authored Jun 24, 2011
26
27 # Install
3c6dd8e @grosser pimp my readme
authored Jun 24, 2011
28 (only tested on rails 2 atm)
16a9900 @grosser initial
authored Jun 24, 2011
29
3c6dd8e @grosser pimp my readme
authored Jun 24, 2011
30 ./script/plugin install git://github.com/grosser/virtual_asset_path.git
16a9900 @grosser initial
authored Jun 24, 2011
31 Or
3c6dd8e @grosser pimp my readme
authored Jun 24, 2011
32 gem install virtual_asset_path
16a9900 @grosser initial
authored Jun 24, 2011
33
34 # Nginx config
35
3c6dd8e @grosser pimp my readme
authored Jun 24, 2011
36 rewrite ^/asset-v[a-z0-9]+(.*) $1; # style: folder
37 ??? # style: suffix
38
39 # Apache config
40
41 ??? # style: folder
42 ??? # style: suffix
43
b35e304 @grosser fix for 3.0.8
authored Jun 25, 2011
44 # Tips
45 - [Speed] MD5 takes ~0.1 ms/file (results are cached per instance if cache_asset_timestamps is active)
46 - [Speed] mtime takes ~0.005 ms/file (...)
47
733d878 @grosser no rails 3.1 support
authored Jun 25, 2011
48 # TODO
49 - Rails 3.1 support -- things got much more complicated ...
50
3c6dd8e @grosser pimp my readme
authored Jun 24, 2011
51 Author
52 ======
53 [Michael Grosser](http://grosser.it)<br/>
54 michael@grosser.it<br/>
55 Hereby placed under public domain, do what you want, just do not hold me accountable...
Something went wrong with that request. Please try again.