注销后Google如何处理“后退"按钮? [英] How Google deals with the Back Button after logout?

查看:76
本文介绍了注销后Google如何处理“后退"按钮?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在网上搜索,试图找到一种避免用户单击后退"按钮时显示以前不合适的信息的好方法.

例如:

  • 为避免注销后查看信息.
  • 为避免发送和处理表单后看到表单.

我查看了这些帖子以及许多其他文章: 避免注销后返回 注销后防止后退按钮

我喜欢Google解决方案,但不知道如何实现.当我从Gmail帐户注销,然后单击后退"按钮时,看不到以前的邮件,而是停留在登录"页面上.

我不是要更改或避免使用后退"按钮,我只是想避免显示不适当的数据.

我尝试使用不同的标头和meta,但是它们不起作用.

解决方案

Gmail是一种JavaScript Web服务,因此,当您单击后退"按钮时,静态状态只会加载被拒绝访问后端的JavaScript客户端. /p>

在传统的非Web服务类型的应用程序上,JavaScript可以在每次页面加载时运行,以确保经过身份验证的会话仍然有效.如果用户未通过身份验证,则将其重新回到登录页面.

没有JS,浏览器将只加载缓存的副本.您可以通过添加以下元标记或http标头来禁用缓存:

   header( "Pragma: no-cache" );
   header( "Cache-Control: no-cache" );
   header(  "Expires: 0" );

您还可以使用元标记禁用缓存:

 <meta http-equiv="Pragma" content="no-cache">
 <meta http-equiv="Cache-Control" content="no-cache">

I've been searching the web trying to identify a good way to avoid show previous unsuitable information when the users click the Back Button.

For instance:

  • To avoid see information after logout.
  • To avoid see a form after send and process it.

I reviewed these posts and many others: avoid go back after logout Prevent back button after logout

I like the Google solution but I don't know how is implemented. When I logout from my Gmail account and then I click the Back Button, I'm not able to see my previous mails, I stay at the Login page.

I'm not trying to change or avoid the Back Button, I just want to avoid to show that not suitable data.

I tried to use diferent headers and meta but them didn't work.

解决方案

Gmail is a JavaScript web service, so that when you click the back button the static state is just loads the JavaScript client which is denied access to the backend.

On a traditional non-web service type application could have JavaScript that runs each time the page loads to insure that the authenticated session is still valid. If the user isn't authenticated, bump them back to the login page.

Without JS, the browser is just going to load a cached copy. You can disable caching by adding these meta tags or http headers:

   header( "Pragma: no-cache" );
   header( "Cache-Control: no-cache" );
   header(  "Expires: 0" );

You can also disable caching using meta tags:

 <meta http-equiv="Pragma" content="no-cache">
 <meta http-equiv="Cache-Control" content="no-cache">

这篇关于注销后Google如何处理“后退"按钮?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆