Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
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

This comment has been minimized.

Show comment Hide comment
@knagode

knagode Sep 8, 2017

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

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