All threads / Force client browser to clear cache after tenant switch

Ask A Question

Notifications

You’re not receiving notifications from this thread.

Force client browser to clear cache after tenant switch

Dan Tappin asked in General

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:

https://stackoverflow.com/questions/49547/how-do-we-control-web-page-caching-across-all-browsers

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.

Join the discussion

Want to stay up-to-date with Ruby on Rails?

Join 33,665+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.

    logo Created with Sketch.

    Ruby on Rails tutorials, guides, and screencasts for web developers learning Ruby, Rails, Javascript, Turbolinks, Stimulus.js, Vue.js, and more. Icons by Icons8

    © 2020 GoRails, LLC. All rights reserved.