473,472 Members | 1,736 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Explanation of this header cache code

dmjpro
2,476 Top Contributor
<%response.addHeader("Pragma", "No-cache");
response.addHeader("Cache-Control", "no-cache");
response.addDateHeader("Expires", -1);
%>


what is the purpose of this code ...


plz explain me in details ....


thanx in advance .....
Feb 23 '07 #1
8 6496
abctech
157 New Member
<%response.addHeader("Pragma", "No-cache");
response.addHeader("Cache-Control", "no-cache");
response.addDateHeader("Expires", -1);
%>


what is the purpose of this code ...


plz explain me in details ....


thanx in advance .....
Hello,
At the top of every JSP the above header attributes are used to prevent caching.
Now I don't know in depth about 'Caching' but whatever little I know I'll share it with you, for the details we'll have to wait for an expert opinion :)

Well,
Http headers used for cache control to prevent the web pages from being cached by the browser and proxy server.

response.setHeader("Cache-Control","no-cache"); //prevents disk caching (HTTP 1.1)
response.setHeader("Pragma","no-cache"); //prevents disk caching (HTTP 1.0)
response.setDateHeader ("Expires", 0); //prevents caching at the proxy server

I'm not really sure about response.addDateHeader("Expires", -1);
I think its to be used for web pages which have information subject to change promptly, such pages do remain in the disk cache of the IE to be used when the user hits back/forward but when the user actually sends a request for such a page the browser fetches the updated version from the web server.
Feb 23 '07 #2
dmjpro
2,476 Top Contributor
lot of thanx

well ...

i think response.addHeader("Expires",-1) means that the cache control prevention for only that browsing session ..

as early as the browsing session exits then the cache control starts again

am i right ...

manyyyyy thanx again
Feb 24 '07 #3
r035198x
13,262 MVP
I will just say that in response.addHeader("Expires",-1)

-1 is the expiration time. The value -1 means that there is no expiration time set.
Feb 24 '07 #4
dmjpro
2,476 Top Contributor
thanx for ur reply ......

one more thing i want to know that where the cache happens ...

i mean does it happen in local memory or into the disk

my problem occures as long as the same browsing session remains..
after the browsing sessoin ends then the updated page shown

plz help me out ...
again thanx in advance
Feb 24 '07 #5
abctech
157 New Member
thanx for ur reply ......

one more thing i want to know that where the cache happens ...

i mean does it happen in local memory or into the disk

my problem occures as long as the same browsing session remains..
after the browsing sessoin ends then the updated page shown

plz help me out ...
again thanx in advance
I think its the disk, isn't our surfing history stored in those 'History','Temporary Internet Files' and some other such temporary folders on our hard drive?

P.S:
By the way, can I ask you in which class/interface is the addDateHeader(String,int) method located?
Feb 24 '07 #6
r035198x
13,262 MVP
By the way, can I ask you in which class/interface is the addDateHeader(String,int) method located?
javax.servlet.http.HttpServletResponse
Feb 24 '07 #7
abctech
157 New Member
javax.servlet.http.HttpServletResponse
Thanks,
Got it.

Interface- 'HttpServletResponse'
public void addDateHeader(java.lang.String name,long date);

dmjpro-
Here's a link I just came across regarding preventing caching of web pages(but its only for IE)
Feb 24 '07 #8
dmjpro
2,476 Top Contributor
thanx a lot ....
Feb 24 '07 #9

Sign in to post your reply or Sign up for a free account.

Similar topics

18
by: Frank Thorstens | last post by:
Hi, i try to give my script headers so the output text would be downloaded in the client's browser and not displayed. But it doesn't work at all in my IE 6 and Opera. <?...
5
by: velthuijsen | last post by:
I have a function that before I modified it took around 13.75 seconds to complete after the modification it took .325 seconds to complete. the function header: (Point **Input, size_t InputSize,...
5
by: Erwin Kloibhofer | last post by:
what if i have a webpage that displays the text "please wait, this may take a few seconds..." and it now waits until some event on the server happens. whatever this is, this can be quick, but it...
0
by: Keith Chadwick | last post by:
I am migrating an existing ASP application over to .NET as a learning exercise. The existing application uses a lot of xsl and xml transformations to render each page. Stored as an application...
2
by: Timo | last post by:
I've set my aspx page to expire immediately using the management console, HTTP headers tab. Considering this scenario: a user visits the aspx page in question, then moves to another page, then...
2
by: mykyp | last post by:
Hi, I am trying to use my vb.net app as a replacement to a normal browser to interface with a website. I am trying to achieve 2 things: 1) logon to the website 2) complete forms and submit data...
19
by: lawrence k | last post by:
How can I find out where my script is outputting to the screen for the first time? My error logs are full of stuff like this: PHP Warning: session_start(): Cannot send session cache...
8
by: anukedari | last post by:
Hi, Could any boby please help to get the answers for the following questions: Is Apache always sends "X-Cache:MISS" header even when caching is off (disable)? or Can we say that cache...
2
by: helveticus | last post by:
I'm having difficulties setting the expires header for images and css files in my compression HttpModule. Compression is carried out by context_BeginRequest and works fine (code not shown)....
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.