This week's book giveaway is in the Object Relational Mapping forum.
We're giving away four copies of Pro JPA 2: Mastering the Java Persistence API and have Mike Keith and Merrick Schincariol on-line!
See this thread for details.
[Logo] JavaRanch » JavaRanch Saloon
  Search | FAQ | Recent Topics | Hot Topics
Register / Login


Reply Bookmark it! Watch this topic JavaRanch » Forums » Java » Servlets
 
RSS feed
 
New topic
Author

Caching the web page in client machine's browser

Rajendiran R. prakash
Greenhorn

Joined: Nov 22, 2007
Messages: 19

Hi Friends,
I'm struck up with one issue in caching the web page in client machine's temporary internet files. I have designed a secured web application. I used

<%
response.setHeader("Cache-Control","no-cache");
response.setHeader("Pragma","no-cache");
response.setDateHeader ("Expires", 0);
%>
for not storing the web page in client machine. Now only some of the pages that doesn't needs the security needs to be cached in the client machines temporary internet files.
For that i used the code as
<%
response.setHeader("Cache-Control","public");
response.setHeader("Pragma","public");
response.setDateHeader ("Expires", 0);
%>
Still i'm unable to store. Please help me solve this. Thanks in Advance. Quick help would be greatly appreciated.

Thanks and regards,
Prakash
David O'Meara
Sheriff

Joined: Mar 06, 2001
Messages: 11870

I tend to use something like these when encouraging resources to be cached:


Bad things happen when good people do nothing
[JavaRanch FAQ] [twitter] [Blog] [Book Promotions] [DbTamer]
Rajendiran R. prakash
Greenhorn

Joined: Nov 22, 2007
Messages: 19

Hi friend,
Thanks for the quick reply. But it doesn't work. Is there any other idea.


Thanks & Regards
Prakash...
Ben Souther
Sheriff

Joined: Dec 11, 2004
Messages: 13039

Originally posted by Rajendiran R. prakash:
Hi friend,
Thanks for the quick reply. But it doesn't work. Is there any other idea.


Thanks & Regards
Prakash...


Maybe you could give us a little more to work with than "it doesn't work".
How do you know it doesn't work?
What did you do to test it?
What were you expecting?
What did you see?

I, for one, wouldn't spend very much effort to help you after seeing how quickly you dismissed David's response.

[ March 13, 2008: Message edited by: Ben Souther ]
[ March 31, 2008: Message edited by: Ben Souther ]

Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples
Rajendiran R. prakash
Greenhorn

Joined: Nov 22, 2007
Messages: 19

Hi Ben,
When i used the above code with some slight alterations, it works for my system(Stand alone). But when i tried with another system with this systems url it doesn't works. Help me please....
Sorry if it hurts David.........
Regards,
Prakash.


It Would be helpful if it is still clear....
Rajendiran R. prakash
Greenhorn

Joined: Nov 22, 2007
Messages: 19

Hi Ben and David,

Sorry for that. It really hurts some one who help others. It works perfectly for me. I used the david's code with some alterations. Now i changed my code according to David's code. While i use that exactly the same way, it works perfectly. Also I had some browser issue. Once i reset it to default settings and tried it works fine.
David O'Meara
Sheriff

Joined: Mar 06, 2001
Messages: 11870

Thanks for the feedback.

This is an important issue with respect to caching or not caching data on the client. Anything you do is just a request to the client and they are free to do what they want. That is, you can ask them to cache the code and they may decide not to, or you may ask them to cache the data and they may decide not to.

Bad things happen when good people do nothing
[JavaRanch FAQ] [twitter] [Blog] [Book Promotions] [DbTamer]
Rajendiran R. prakash
Greenhorn

Joined: Nov 22, 2007
Messages: 19

Thank you David,
I feel sorry for that reply.
David O'Meara
Sheriff

Joined: Mar 06, 2001
Messages: 11870

Nothing personal

I should also point out that the best you can do is look at the response headers too make sure the headers are being sent.

Bad things happen when good people do nothing
[JavaRanch FAQ] [twitter] [Blog] [Book Promotions] [DbTamer]
 
 
 
Reply Bookmark it! Watch this topic JavaRanch » Forums » Java » Servlets
 
RSS feed
 
New topic
IntelliJ open source