I have two options for implementing caching in my web application. I can either add a Varnish cache outside of my application code, and cache the responses on a per-request URL basis, or I can use an in-memory cache like memcached to store the results of database accesses.
I am having a hard time choosing between these two implementations. I think adding Varnish results in less code (don't have to add logic around whether to cache a database result or not), but there is a little more overhead in terms of infrastructure to add the Varnish caching layer.
What are other benefits of using one solution over the other? And are there other important things I haven't considered?