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
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With