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 presse开发者_JAVA技巧s 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:
- Go to the home page logged out.
- Enter your credentials and click log in
- Once logged in, press back button to go back to home page.
- 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.
Send the appropriate headers instructing the browser not to cache that page.
精彩评论