I have a basic web app that given a url, hits a database, does some maths and returns some html. The result is a bit heavy to calculate but the results can be cached for sometime.
Is there any reason to add caching to my web application when I could just put a cache like Varnish in front of the web server?
If it’s possible for you to do in Varnish, and you know how to configure, tune, maintain and monitor Varnish, then I would recommend on doing it in Varnish. If however Varnish is new for you and you have experience with application-based caching, I would recommend that instead.
Doing a cache both in Varnish and in your app could potentially add another layer of complexity to your software stack, which is not desirable.