如何正确注销GWT应用程序以避免浏览器加载缓存数据

How to properly logout from GWT app to avoid browser loading cached data?

本文关键字:浏览器 加载 缓存 数据 何正确 注销 GWT 应用程序      更新时间:2023-09-26

我有一个基于 GWT 构建的企业 Web 应用程序,可通过外部身份验证模块进行访问。我的问题是:

  • 我使用登录页面登录到应用程序。
  • 被定向(使用反向代理规则)到我的Tomcat服务器,在那里我加载了我的GWT应用程序。
  • 使用应用。
  • 我退出应用程序。
  • 当我尝试重新登录时,我没有得到登录页面。

如果我再次键入登录页面的 URL,浏览器将开始加载缓存的数据,我无法进入登录页面。我必须点击重新加载才能进入登录页面。这怎么可能?F5 有什么特别之处,告诉浏览器不要使用缓存?

我知道代理不会被我的任何请求击中,这意味着浏览器所做的只是加载缓存的元素。

有人有什么线索吗?

我没有清楚地理解你的问题,但我想我有一个类似的问题。希望对您有所帮助。

我有我的GwtPage.html所有GWT的东西都保护在web.xml中。

当我第一次访问 http://example.com/GwtPage.html 时,容器的安全性将我发送到登录名.jsp。登录完成后,我被发送到GwtPage.html,所以一切都很好。

但是第二次浏览器

缓存了 GwtPage.html,容器没有向我发送登录名.jsp。所以我做了以下工作:我创建了索引.jsp只有一行:

<%
    response.sendRedirect("GwtPage.html");
%>

并将其添加到受保护的资源列表中。

浏览器不会缓存它,因此容器总是向我发送登录页面。

第二个好处是 GwtPage.html 仍然被浏览器缓存,这是非常好的,因为它非常重。

我的网站.xml:

<welcome-file-list>
    <welcome-file>index.jsp</welcome-file>
</welcome-file-list>
<!-- Security -->
<security-constraint>
    <web-resource-collection>
        <web-resource-name>Index Page</web-resource-name>
        <url-pattern>/index.jsp</url-pattern>
    </web-resource-collection>    
    <web-resource-collection>
        <web-resource-name>Main Page</web-resource-name>
        <url-pattern>/GwtPage.html</url-pattern>
    </web-resource-collection>
    <web-resource-collection>
        <web-resource-name>Gwt entrails</web-resource-name>
        <url-pattern>/Gwt/*</url-pattern>
    </web-resource-collection>
    <auth-constraint>
        <role-name>VIEWER</role-name>
    </auth-constraint>
</security-constraint>
<login-config>
    <auth-method>FORM</auth-method>
    <realm-name>myrealm</realm-name>
    <form-login-config>
        <form-login-page>/LoginForm.jsp</form-login-page>
        <form-error-page>/LoginError.jsp</form-error-page>
    </form-login-config>
</login-config>

我遇到了同样的问题。注销后 GWT 模块未启动。

<a id="logout" href="${pageContext.request.contextPath}/j_spring_security_logout">Logout</a>

解决方案非常简单,应该在打开登录页面
之前自动刷新

春季安全.xml

<security:logout logout-success-url="/logout.html"/>

注销.html

<head lang="en">
  <meta http-equiv="REFRESH" content="0;  url=login.html">
</head>