aspose file tools*
The moose likes Servlets and the fly likes Servlet Caching Problem!!!!!!!!!!!!!!!!! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Servlet Caching Problem!!!!!!!!!!!!!!!!!" Watch "Servlet Caching Problem!!!!!!!!!!!!!!!!!" New topic
Author

Servlet Caching Problem!!!!!!!!!!!!!!!!!

sunilkumar ssuparasmul
Ranch Hand

Joined: Dec 13, 2000
Posts: 142
Hi All
I have a servelt which needs to do cahching. The prablem is here Whenevr a update happens to the DB through some other process then the cahce should be reflected .
Can some one suggest the best way yo do it using servelts .
Thnaks in advance

Cheers
sunil.s


"Winners don't do different things<br /> They do things differently"
Hartmut Ludwig
Ranch Hand

Joined: Aug 31, 2002
Posts: 51
Hi, Sunil,
Originally posted by sunilkumar ssuparasmul:

I have a servelt which needs to do cahching. The prablem is here Whenevr a update happens to the DB through some other process then the cahce should be reflected.

Well, what caching do you talk about? The Browser-cache on the client-side or a Proxy-cache?
Generally it makes not much sense to cache a Servlet with DBMS-Connect. The data is always changing, with every single request. If not so you would not need a database.
(Correct me folks, if I am wrong with this).
If you have trouble because a proxy-cache is not revalidating your requests, you can set the Response-Headers to force the client to revalidate from server, not from proxy-cache.
So using :

forces the Client to always request this document from original server, while:

avoids caching on the client-side (Browser).
Those cache directives are only available on HTTP1.1 enabled servers.
Anyway you said your Servlet "needs to do caching". That means you have a lot of "static" content in it which is not changing very often. In this case it may be a good idea to create a separate servlet only for DB-access and another Servlet which contains more "static" data and therefore can make use of caching.
Good luck
Hartmut
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12835
    
    5
I think we need to know more about the other process(es?) that may modify the database.
How often is the database modified?
Can you have this other process notify your servlet or leave some indication of when the database was last modified somewhere where the servlet can see it?
Is it feasible to cache the entire page that the servlet writes, or just the database part?
You can certainly make a huge improvement in performance under the right conditions.
Bill
sunilkumar ssuparasmul
Ranch Hand

Joined: Dec 13, 2000
Posts: 142
Actually , I have a servlet which gets data from DB.
This DB is updated by mainframes through some process.
My question is is there any architecture which wud allow my servlet to do a reload the DB content only when the DB is changed. Its more or less like having a read only EJB ib weblogic.

Any idea how do i go abpout implementing this?
THnaks in advance
sunil.s
 
 
subject: Servlet Caching Problem!!!!!!!!!!!!!!!!!