简体   繁体   English

当在rails中按下浏览器的后退按钮时,在注销后进入登录页面

[英]Be on login page after Logout when press back button of Browser in rails


I have observe Facebook and Gmail that when we logged out it redirects us to the login page, but the interesting is that when we hit back button it still not go to inbox page.我观察到 Facebook 和 Gmail 当我们注销时它会将我们重定向到登录页面,但有趣的是当我们点击返回按钮时它仍然不是 go 到收件箱页面。
I have search in google and got something to set attribute "Cache-control" in header.我在谷歌搜索并在 header 中设置属性“缓存控制”。 But I don't know how can we implement this mechanism in Rails.但我不知道我们如何在 Rails 中实现这种机制。
Can anybody suggest me how to do that?有人可以建议我怎么做吗?
My Rails version is 3.0.6 with Ruby1.9.2我的 Rails 版本是 3.0.6 和 Ruby1.9.2

You want to set the headers of your page to prevent caching您想设置页面的标题以防止缓存

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM