Created
March 26, 2009 19:52
-
-
Save jqr/86281 to your computer and use it in GitHub Desktop.
Nginx cache busting rewriter
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Nginx cache busting rewriter, best used on assets that have long-lived expires. | |
# | |
# Rewrites like so: | |
# blah.com/release_ab2ea212312.../file.css => blah.com/file.css | |
# | |
location ~ ^/release_(.*?)/ { | |
rewrite ^/release_(.*?)/(.*)$ /$2 last; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# A paperclip initializer, place in config/initializers/ | |
Paperclip::Attachment.interpolations[:release_path] = | |
lambda do |attachment, style| | |
unless AssetVersion.version.blank? | |
"/release_#{AssetVersion.version}" | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class SomeModel < ActiveRecord::Base | |
has_attached_file :image, { | |
:styles => { | |
:thumb => "100x100", | |
}, | |
:url => ":release_path/attachments/:class/:attachment/:id/:style/:basename.:extension", | |
:path => ":rails_root/public/attachments/:class/:attachment/:id/:style/:basename.:extension", | |
:default_url => "/images/:class/:attachment/missing_:style.png", | |
} | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment