Page Caching Discussion

xiaoxiao2021-03-06  71

Fixing problems with JSP and caching proxy server Many of the proxy servers in use today are caching servers. These servers tend to recognize cgi, asp, and cfm as dynamic. They then always request a new page from the server rather than giving their client the page from the proxy cache. The problem is that most of these proxies do not recognize jsp as dynamic. To make matters worse, if the proxy server asks for the last modified date from the jsp page, it gets the compile date.There is a Simple fix for this. add the fol your jsp Pages Where You Have this Problem.

%! Return Current Time To Proxy Server Requestpublic Long getlastModified (httpservletRequest Request) {return system.currenttimemillis ();}%

To Ensure That The Web-Browser Itself Will Always Obtain The Latest Version of The Page, The Following Can Be Added To The Beginning Of Your Jsp (Before Any Content Has BEEN COMMITTED.

Response.setHeader (cache-control, no-cache); response.setheader (Pragma, no-cache); response.setInTheader (Expires, 0); ----------------- -------------------------------------------------- ----------- Comment: i Have Used this tags in My JSP Page WHERE IM USING Post Method.% Response.setHeader (cache-control, no-cache); response.setheader (Pragma, NO- Cache); response.setInTheader (Expires, 0);%

Now the problem is wherever i subsmit my form me this warning ....... SO i m not able to view my page .....

Warning Page has Expired The page you requested was created using information you submitted in a form. This page is no longer available. As a security precaution, Internet Explorer does not automatically resubmit your information for you. To resubmit your information and view this Web page , Click The Refresh Button .---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ---------------------------------- You Can Stop Pages Caching Their Data ... It's a pain (as there Are Buggy Browsers Out There, But this Works for US: <% // Set To Expire Far in The Past. Response.setHeader ("Expires", "SAT, 6 May 1995 12:00:00 GMT");

// set Standard http / 1.1 no-cache headers. Response.setHeader ("Cache-Control", "No-cache, must-revALIDATE");

// SET IE EXTENDED HTTP / 1.1 NO-Cache Headers (Use addheader). Response.addheader ("Cache-Control", "Post-Check = 0, pre-check = 0");

// set standard http / 1.0 no-cache header. Response.setHeader ("Pragma", "NO-Cache");%> --------------------- -------------------------------------------------- ------- You will need to set the appropriate HTTP header attributes to prevent the dynamic content output by the JSP page from being cached by the browser. Just execute the following scriptlet at the beginning of your JSP pages to prevent them from Being cached at the broser.

You NEED BTH The Statements to Take Care of Some of the Older Browser Versions .SetHeader ("Cache-Control", "No-cache"); // http 1.1Response.setheader ("Pragma", "NO- Cache "); // http 1.0Response.SetDateHeader (" expires ", 0); // prevents Caching At the Proxy Server%> If The Above Fails, Try Changing The first line to response.setHeader (" cache-control ", "no-store"); // HTTP 1.1The difference between no-cache and no-store is a bit dodgy, but apparently no-cache is the more polite keyword However, please note that there are some problems with disabling page caching. under IE 5.0 due to the unique buffering requirements of the browser Please see the Microsoft knowledge base for details:. http: //support.microsoft.com/support/kb/articles/Q222/0/64.ASPhttp: // support. Microsoft.com/support/kb/articles/q234/2/47.asp

I Added this code to the page.

>

Added for all browsers. <% response.setheader ("cache-control", "no-cache"); // http 1.1Response.setheader ("prgma", "no-cache"); // http 1.0Response.setdateHeader ("expires", -1);%>

I am Also doing this at the Very Bottom of the JSP File:

转载请注明原文地址:https://www.9cbs.com/read-91487.html

New Post(0)