Ehcache or varnish or both?
should one use ehcache in favor of varnish? or the other way a开发者_如何学Cround? or both?
On some projects I use both. EHCache is perfect for intermediary results of any type (rescaled images, query results, transformed data) used by your servers. You have to adapt your software to use it though. Varnish is a transparant add-on layer for HTTP-level result caching. If you would use EHCache to cache HTTP end-results, it's a lot of work to get your implementation behave correctly according to the HTTP protocol cache behavior, you have to devise some invalidation/purging/debugging solution, avoid cache-rushes, and implemented in synchronous Servlet technology (e.g. Filter or Servlet) it won't scale as well as Varnish...
So, I would recommend Varnish for HTTP-result caching, and EHCache for intermediary, in-app result caching.
精彩评论