简体   繁体   中英

Automatic page reload when accessed from pressing the back button

I have a RoR site that loads a splash page on the first visit. It's simply a page with information about the service and a form to enter credentials. When the user logs in, the form submits to the same page (document root) but if the user is logged in successfully, the actual site is loaded. My issue is that when the user presses the back button, they're taken back to the log in/splash page. This makes sense because the browser has cached the page, but I'd like it if I could somehow tell that the page is being shown from cache and reload it.

You can see the same functionality on facebook.com:

  1. Go to the home page logged out.
  2. Enter your credentials and click log in
  3. Once logged in, press back button to go back to home page.
  4. Page will automatically reload to bring you to your logged in state.

Set a cookie upon login. Have the home page check for the cookie and redirect accordingly.

发送适当的标头,指示浏览器不要缓存该页面。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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