Created
October 4, 2012 22:15
-
-
Save joslynesser/3836818 to your computer and use it in GitHub Desktop.
Skipping Rack::Cache for authenticated users
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ... | |
config.middleware.insert_before "Rack::Cache", "SkipCache" | |
# ... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Does this work when multithreading is turned on (e.g. if we are using Puma)?