Created
February 16, 2014 02:14
-
-
Save metaskills/9028312 to your computer and use it in GitHub Desktop.
Do Not Cache Rails/Sprockets Assets In Development
This file contains 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
# In config/initializers/sprockets.rb | |
require 'sprockets' | |
require 'sprockets/server' | |
Sprockets::Server.class_eval do | |
private | |
def headers_with_rails_env_check(*args) | |
headers_without_rails_env_check(*args).tap do |headers| | |
if Rails.env.development? | |
headers["Cache-Control"] = "no-cache" | |
headers.delete "Last-Modified" | |
headers.delete "ETag" | |
end | |
end | |
end | |
alias_method_chain :headers, :rails_env_check | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment