The actual test of code that jsp can really disable browser cache is effective.

Source: Internet
Author: User

This problem has plagued me for a long time. The previous method was to use JS, And now I finally found a solution:

Popular online versions:

<%
    response.setHeader("Pragma", "No-cache");
    response.setHeader("Cache-Control", "no-cache");
    response.setDateHeader("Expires", 0);
%>

I tested the actual effective version:

<%
    response.setHeader("Pragma", "No-cache");
    response.setHeader("Cache-Control", "no-cache");
    response.setHeader("Cache-Control", "no-store");
    response.setDateHeader("Expires", 0);
%>

Note: I add it to JSP files that do not require the browser to cache. The following is an example:

<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%
    response.setHeader("Pragma", "No-cache");
    response.setHeader("Cache-Control", "no-cache");
    response.setHeader("Cache-Control", "no-store");
    response.setDateHeader("Expires", 0);
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    
        <meta http-equiv="Expires" content="0">
        <meta http-equiv="Cache-Control" content="no-cache">
        <meta http-equiv="Cache-Control" content="no-store">
        <meta http-equiv="Pragma" content="no-cache">
<Title> List page </title>
<Meta http-equiv = "Description" content = "List users for Operation">
    

    <body>
        <form name="manage" action="/user_manage/delUser" method="post">
            <s:iterator value="list" status="user">
                <input type="checkbox" name="user.delId"
                    value="<s:property value="id" />">
                <s:property value="username" />
                <s:property value="password" />
                <br />
            </s:iterator>
<A href = javascript: Manage. Submit ();> Delete the selected user </a>
        </form><br />
<A href = "/logout"> log out </a>
        <s:debug></s:debug>
    </body>

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.