Skip to content

Instantly share code, notes, and snippets.

@joslynesser
Created October 4, 2012 22:15
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save joslynesser/3836818 to your computer and use it in GitHub Desktop.
Skipping Rack::Cache for authenticated users
# ...
config.middleware.insert_before "Rack::Cache", "SkipCache"
# ...
class SkipCache
def initialize(app)
@app = app
end
def call(env)
request = Rack::Request.new(env)
if request.cookies["your_authenticated_cookie_name"]
env["rack-cache.force-pass"] = true
end
@app.call(env)
end
end
@knagode
Copy link

knagode commented Sep 8, 2017

Does this work when multithreading is turned on (e.g. if we are using Puma)?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment