Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java Tomcat enable caching

What is the best way to set up caching on tomcat?

Also how caching works?Is it url based,dir based or what?
I need url specific caching so the database don't make the same calculations for the same url's

like image 743
Argiropoulos Stavros Avatar asked Sep 28 '10 14:09

Argiropoulos Stavros


1 Answers

The simplest way, is to use a dedicated web cache provider. Tomcat does not have one OOTB, but you could employ Apache with mod_cache (and obviously mod_jk). In this configuration, Apache tends to act as a proxy-cache that caches the dynamic content served by Tomcat; you will have to ensure that Tomcat serves the right headers to ensure that Apache will cache the responses.

There are other commerical web-cache solutions, but they're typically used for high-end uses.

You could also employ Squid instead of Apache, to act as a reverse proxy that is also capable of serving cached content; in this case, Squid performs caching of the dynamic content.

If you do not wish to invest in an additional server, like the above solutions suggest, you might consider using EHCache to perform web page caching on Tomcat itself.

Related

  1. Java Web Application: How to implement caching techniques?
like image 193
Vineet Reynolds Avatar answered Sep 28 '22 19:09

Vineet Reynolds