Disable Rack Cache lookup in presence of session cookie
config/environments/production.rb
config.action_dispatch.rack_cache[:allow_reload] = true
config/application.rb
config.middleware.insert_before Rack::Cache, ":RackCacheInvalidator"
lib/rackcacheinvalidator
class RackCacheInvalidator
def initialize application
@application = application
end
def call(environment)
if environment['HTTP_COOKIE'].include?(session_key)
environment['HTTP_PRAGMA'] = 'no-cache'
end
@application.call environment
end
def session_key
Rails.application.config.session_options[:key]
end
end
Written by Arnaldo Ignacio Gaspar Véjar
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Session
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#