Tuesday 19 February 2013

Disable browser cache while using devise gem -rails 3

While using devise gem for authentication, I found that even after a user log out, he can still see the previous page he visited if he clicks on the back button of browser. To disable this add the following code in your application_controller.rb.


before_filter :set_no_cache
def set_no_cache


   response.headers["Cache-Control"] = "no-cache, no-store, max-age=0, must-revalidate"
   response.headers["Pragma"] = "no-cache"
   response.headers["Expires"] = "0"


end

No comments:

Post a Comment