Tags: jsp2014-05-16 11:29 2972 People read comments (0) favorite reports Classification:JSP
(1)
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
How the JSP disables caching
Using server-side control Ajax page Caching:
Response.setheader ("Pragma", "No-cache");
Response.AddHeader ("Cache-control", "must-revalidate");
Response.AddHeader ("Cache-control", "No-cache");
Response.AddHeader ("Cache-control", "No-store");
Response.setdateheader ("Expires", 0);
Simple use of Xmlhttp.setrequestheader ("Cache-control", "No-cache") is invalid.
Cache-control header Field
CACHE-CONTROL Specifies the caching mechanism that requests and responses follow. Setting Cache-control in a request message or response message does not modify the caching process in another message processing process. The cache directives for the request include No-cache, No-store, Max-age, Max-stale, Min-fresh, only-if-cached, and the instructions in the response message include public, private, No-cache, No-store, No-transform, Must-revalidate, Proxy-revalidate, Max-age. The instructions in each message have the following meanings:
Public indicates that the response can be cached by any buffer.
Private indicates that the entire or partial response message for a single user cannot be shared with the cache. This allows the server to simply describe a partial response message for the user, and this response message is not valid for another user's request.
No-cache indicates that a request or response message cannot be cached
No-store is used to prevent the inadvertent release of important information. Sending in the request message will make the request and response messages do not use the cache.
Max-age indicates that the client can receive a response that is not longer than the specified time (in seconds).
Min-fresh indicates that the client can receive a response that is less than the current time plus a specified time.
Max-stale indicates that the client can receive a response message that exceeds the timeout period. If you specify a value for the Max-stale message, the client can receive a response message that exceeds the specified value for the timeout period.
Disable IE Caching
The HTTP message header includes the normal header, the request header, the response header, and the entity header.
The Cache-control in the normal header is used to specify the cache instruction, the cache instruction is unidirectional (the cache instruction appearing in the response may not appear in the request), and is independent (the cache instruction of one message does not affect the caching mechanism of another message processing). HTTP1.0 uses a similar header field for pragma.
The cache instructions for the request include: No-cache (for instructions or response messages not cached), No-store, Max-age, Max-stale, Min-fresh, only-if-cached;
Cache directives for response include: public, Private, No-cache, No-store, No-transform, Must-revalidate, Proxy-revalidate, Max-age, S-maxage.
Example: In order to instruct IE browser (client) not to cache the page, the server-side JSP program can be written as follows:
Response.setheader ("Cache-control", "No-cache");
Response.setheader ("Pragma", "No-cache"), function equivalent to the upstream code, usually in combination
The Expires Entity header field gives the date and time when the response expires. In order for a proxy server or browser to update a page in the cache after a period of time (once again accessing pages that have been visited, loading directly from the cache, shortening response times, and reducing server load), we can use the Expires entity header domain to specify the page expiration time. Example: expires:thu,15 SEP 2006 16:23:12 GMT
The HTTP1.1 client and cache must treat other illegal date formats (including 0) as expired. For example: In order to let the browser do not cache the page, you can also use the Expires entity Customs domain, set as the 0,JSP program as follows:
Response.setdateheader ("Expires", "0");
JSP disables caching in the Way Response.setheader ("Pragma", "No-cache"); Setdateheader ("Expires", 0);