Common Methods for disabling cache in JSP

Source: Internet
Author: User

Disable cache settings on jsp pages

1. The client cache should include the following content in <META HTTP-EQUIV = "pragma" CONTENT = "no-cache">
<META HTTP-EQUIV = "Cache-Control" CONTENT = "no-cache, must-revalidate">
<META HTTP-EQUIV = "expires" CONTENT = "Wed, 26 Feb 1997 08:21:57 GMT">
Or

<Meta http-equiv = "pragma" content = "no-cache">
<Meta http-equiv = "cache-control" content = "no-cache">
<Meta http-equiv = "expires" content = "0">

2. Disable caching on the dynamic web page of the server. Add a script similar to the following:
Response. setHeader ("Pragma", "No-cache ");
Response. setHeader ("Cache-Control", "no-cache ");
Response. setDateHeader ("Expires", 0 );

3. Set a limited time Cache
Int minutes = 10;
Date d = new Date ();
String modDate = d. toGMTString ();
String expDate = null;
ExpDate = (new Date (d. getTime () + minutes * 60000). toGMTString ();
Response. setHeader ("Last-Modified", modDate );
Response. setHeader ("Expires", expDate );
Response. setHeader ("Cache-Control", "public"); /// HTTP/1.1
Response. setHeader ("Pragma", "Pragma"); /// HTTP/1.0
Suggestion: It is recommended that jsp cache be implemented on the filter, so that the pages to be buffered are concentrated in the same directory. You only need to modify web. xml to complete the buffer settings for each change, which is more convenient.

4. If none of the above methods works, add a tail after your normal URL.

Select in JS

Var timestamp = (new Date (). valueOf ();

URL + "& timestamp =" + timestamp;

Select

Long timestamp = new Date (). getTime ();

URL + "& timestamp =" + timestamp;

In this case, your URL is always changing, and the browser will have to update it honestly, and there is no buffer available.

 

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.