File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JSP and the fly likes Caching Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "Caching" Watch "Caching" New topic


David Attard

Joined: May 13, 2003
Posts: 26
Sometimes I worry about performance on our web-apps, anyone can offer tools/tips/techniques for caching certain parts of better performance?

There's no place like
Matt Rasking

Joined: Feb 12, 2002
Posts: 15
Depends on your application. If you're building/maintaining a global application you might want to look into hosted content like Akamai, Keynote, Pivia or into Application Delivery Networks (there was a good article on on this recently).
If you're question is more towards the feasibility of caching anything for a web application than gif/js/static content is always good to look at. Storing static content on the web server reduces lookup times for these elements, which in turn reduces network traffic between your web servers and app servers. Of course if you're in a small intranet environment you might as well cache these things on the clients themselves, but the effort maintaining these caches and distributing content outweigh the performance improvements.
Web Servers and reverse proxies usually offer different levels of caching. Check out for a list of products and research in this area.
Jay Dellinger

Joined: Sep 19, 2002
Posts: 12
Yeah, depends on the application. As far as code performance, first tip would be use pooled database connections. Next, if you retrieve and display a lot of data, examine what you are showing and determine if you really have to load it fresh on every page view. If you show information that typically will not change for a day or longer, consider loading it on startup and caching it. Just remember to provide a way to manually refresh it at any time (admin page) as well as a scheduled refresh as well (I like to use TimerTasks). Don't create caches that can only be refreshed by restarting the server....that's just messy.
Also, consider running a profiler against your code. If you see an inordinate amount of instances of one or more objects being created to perform repeated tasks, you may want to consider either refactoring that logic, or using object pools. Object pools can help offset performance problems when going from low load to a sudden spike of activity in object heavy code. Also look for a lot of time being spent in specific sections of code...perhaps the logic there could be improved to reduce the slowdown.
Finally, make sure you consider and address multi-threaded access to your cached data. You don't want your caches to get corrupted or invalidated because two threads try to modify at the same time.
my 2 cents.
I agree. Here's the link:
subject: Caching
It's not a secret anymore!