注销后避免后台页面呈现 [英] Avoid back page rendering after sign out in

查看:109
本文介绍了注销后避免后台页面呈现的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我见过:


在这里输入链接描述

我在JSF 1.2页面中使用了:

I've used in JSF 1.2 pages:

<meta http-equiv="Cache-control" content="no-store, no-cache, must-revalidate"/>
<meta http-equiv="Pragma" content="no-cache" />
<meta http-equiv="Expires" content="-1"/>

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE8"/>

在IE8 e Chrome中无法使用!当我使用后退按钮时,它会再次显示页面!
出了什么问题?
Regards。

It did not work in IE8 e Chrome! When I use the back button it shows the page again! What is wrong? Regards.

推荐答案

以下是如何在所有浏览器中控制网页缓存?忽略:

Here's a cite from How to control web page caching, across all browsers? which you linked in your question but apparently overlooked:


请注意,当通过HTTP提供页面并且两者都存在标题时,HTTP响应标题和HTML元标记,那么响应标题中指定的标题将优先于HTML元标记。只有在从本地磁盘文件系统查看页面时,才会使用HTML元标记。另请参阅 W3 HTML规范章节5.2.2 。请不要以编程方式指定它们,因为Web服务器可以包含一些默认值。要验证这一个,你可以使用Firebug Net面板来查看/调试它们。

Note that when the page is served over HTTP and a header is present in both the HTTP response headers and the HTML meta tags, then the one specified in the response header will get precedence over the HTML meta tag. The HTML meta tag will only be used when the page is viewed from local disk file system. See also W3 HTML spec chapter 5.2.2. Take care with this when you don't specify them programmatically, because the webserver can namely include some default values. To verify the one and other, you can see/debug them using Firebug Net panel.

显然是这种情况。您需要在真实的HTTP响应中设置这些标头,而不是在其HTML输出中。对于JSF 1.x Web应用程序,最好的方法是创建一个 servlet过滤器来执行该任务。以下是一个开创性的例子:

This is apparently the case. You need to set those headers on the real HTTP response, not in its HTML output. In case of a JSF 1.x web application the best way is to create a servlet filter to perform the task. Here's a kickoff example:

public class NoCacheFilter implements Filter {

    @Override
    public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException {
        HttpServletResponse response = (HttpServletResponse) res;
        response.setHeader("Cache-Control", "no-cache, no-store, must-revalidate"); // HTTP 1.1.
        response.setHeader("Pragma", "no-cache"); // HTTP 1.0.
        response.setDateHeader("Expires", 0); // Proxies.
        chain.doFilter(req, res);
    }

    // ...
}

将它映射到感兴趣的URL模式的 web.xml 中,例如 *。jsf 或者 FacesServlet 的servlet名称。

Map it in web.xml on an URL pattern of interest, e.g. *.jsf or on the servlet name of the FacesServlet.

这篇关于注销后避免后台页面呈现的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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