How to clear browser cache after user logout to prevent access to private info via 'Back' button

后端 未结 3 1442
夕颜
夕颜 2020-12-16 15:36

After a user logs out, if they hit the back button, they can go back to the last page they were on before logging out.

The app I am working on will often be used on

3条回答
  •  盖世英雄少女心
    2020-12-16 15:45

    Use the below code in application controller .. it works for me. Hope this will help you. Thank you!!

    code

    before_filter :set_cache_buster
    
    def set_cache_buster
       response.headers["Cache-Control"] = "no-cache, no-store, max-age=0, must-revalidate"
       response.headers["Pragma"] = "no-cache"
       response.headers["Expires"] = "Fri, 01 Jan 1990 00:00:00 GMT"
    end
    

提交回复
热议问题