Skip to main content
Ask A Question
You’re not receiving notifications from this thread.

Force client browser to clear cache after tenant switch

General • Asked by Dan Tappin

I have a Rail app where the user can switch tenants (activerecord_acts_as_tenant). The issue is that in production the browser is caching the old client HTML etc.

I came across this:

headers["Cache-Control"] = "no-cache, no-store, must-revalidate" # HTTP 1.1.
headers["Pragma"] = "no-cache" # HTTP 1.0.
headers["Expires"] = "0" # Proxies.

I have a controller that sets a session variable and then redirects to root. I want to 'reset' the cache etc. at this point but I can't seem to figure out how to implement this.

It's very bizzare. The browser keeps the old HTML even over manual refreshes. Tried again this morning to have the site even load the page after Devise had timed out. The datatables failed as they were calling JSON from the live site but authentication failed so they throw errors.

Login or Create An Account to join the conversation.

Subscribe to the newsletter

Join 30,242+ developers who get early access to new screencasts, articles, guides, updates, and more.

    By clicking this button, you agree to the GoRails Terms of Service and Privacy Policy.

    More of a social being? We're also on Twitter and YouTube.