Quantcast
Channel: Disable Sprockets asset caching in development - Stack Overflow
Viewing all articles
Browse latest Browse all 4

Answer by MetaSkills for Disable Sprockets asset caching in development

$
0
0

I created the following gist (https://gist.github.com/metaskills/9028312) that does just this and found it is the only way that works for me.

# 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

Viewing all articles
Browse latest Browse all 4

Trending Articles