Skip to content

Instantly share code, notes, and snippets.

@metaskills
Created February 16, 2014 02:14
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save metaskills/9028312 to your computer and use it in GitHub Desktop.
Save metaskills/9028312 to your computer and use it in GitHub Desktop.
Do Not Cache Rails/Sprockets Assets In Development
# 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