JSP page cache and Clear cache

Source: Internet
Author: User
Tags browser cache microsoft frontpage

JSP page cache and Clear cache

I. Overview

The idea of caching can be applied at all levels of software layering. It is an internal mechanism that is not perceptible to the outside world.

The database itself is cached, and persistent layers can be cached. (e.g. hibernate, 1-and 2-level caches)

The business layer can also have a cache (but in general, this is a process domain and will not be cached).

The presentation layer/Data Service layer (the traditional Web presentation layer) can also be set to cache (JSP cache is this layer, implemented in the app

Caching mechanism on the server)

Browser also has a cache (ie, for example) that everyone knows (implementing a caching mechanism on the Web server). The higher the upper

The better the caching effect, the more profound the underlying cache impact.

Second, the cache implementation (browser cache currently accessed JSP dynamic page)

(a), the service-side method:

<%

Response.setheader ("Pragma", "No-cache");

Response.setheader ("Cache-control", "No-cache");

Response.setdateheader ("Expires",-10);

%>

(b), client method:

Meta is the response header message used to simulate an HTTP protocol in an HTML document. Meta tags are used in and of Web pages,

Meta tags are useful for many purposes. There are two types of meta attributes: Name and HTTP-EQUIV. The Name property is primarily used to describe a Web page that corresponds to

Contents (Web content), so that search engine robots find, classify (currently almost all search engines use online robots

Automatically find meta values to categorize Web pages). The most important of these is description (the site's description on the search engine) and

Keywords (categorical keywords), so you should add a meta value to each page. The following are some of the more commonly used:

Name property

1,

2,

3,

4, Tell the search engine the author of your site's production;

5,

The properties are described as follows:

Set to all: The file will be retrieved and the link on the page can be queried;

Set to None: The file will not be retrieved, and the link on the page cannot be queried;

Set to index: The file will be retrieved;

Set to follow: links on the page can be queried;

Set to NOINDEX: The file will not be retrieved, but the link on the page can be queried;

Set to Nofollow: The file will not be retrieved and the link on the page can be queried.

Http-equiv Property

1,

and

Iso-8859-1 character sets, as well as BIG5, Utf-8, Shift-jis, Euc, Koi8-2 and other character sets;

2, timed to let the page within the specified time n,

Jump to page Http;//yourlink;

3, can be used to set the page to

Time, and must be recalled to the server once it expires. It is important to note that the GMT time format must be used;

4,

Page content, set once left the page can not be recalled from the cache;

5, cookie set, if

When the page expires, the saved cookie will be deleted. It is also important to note that GMT time format must be used;

6, page rating, Internet Options in IE, there is a content

Settings, you can prevent browsing some restricted websites, and the limit level of the website is set by the meta attribute;

7, Force the page to display in the current window as a separate page,

You can prevent your Web page from being called by others as a frame page;

8,

Meta http-equiv= "Page-exit" contect= "Revealtrans (duration=20,transtion =6)" > set Enter and leave

Special effect when opening a page, this function is "format/page transition" in FrontPage, but the added page cannot be a

Frame page.

Third, the cache application

(a), Prevent JSP page cache in order to prevent the browser from caching the current Access JSP dynamic page, you can set the following way

<%

Set the expiration date to a past time

Response.setheader ("Expires", "Sat, 6 May 1995 12:00:00 GMT");

Set http/1.1 No-cache Header

Response.setheader ("Cache-control", "no-store,no-cache,must-revalidate");

Set IE extension http/1.1 no-cache headers, users add themselves

Response.AddHeader ("Cache-control", "post-check=0, pre-check=0");

Sets the standard http/1.0 No-cache header.

Response.setheader ("Pragma", "No-cache");

%>

Of course, each page contains this code, which can be cumbersome to handle related pages by means of custom filters (filter)

Surface

(b), jsp,html clear page cache

1. Disable client-side caching to add a similar following to

<meta http-equiv= "Pragma" content= "No-cache" >

<meta http-equiv= "Cache-control" content= "No-cache, must-revalidate" >

<meta http-equiv= "Expires" Content= "Wed, 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 in 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);

(iii) Setting the cache for a limited time

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

Add: A few suggestions about the. JSP cache:

1.jsp Cache is best done on the filter, the need to buffer the page in the same directory, each change only need to change the web.

To complete the buffering setup, which is convenient.

2.Gzip compression can compress the page very small, the average compression ratio for the 1/3,jsp Cache hashmap Buffer Compressed page, certainly more than not

Saves memory consumption and is more efficient before compressing. About gzip refer to this open source

Mesh: Http://sourceforge.net/projects/pjl-comp-filter


JSP page cache and Clear cache

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.