which one is better to use and why?
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.If this question can be reworded to fit the rules in the help center, please edit the question.
The answer to this question is: it depends :)
Based in my experience with caching static content, Varnish is much faster when you have few concurrent connections but loses to squid when you have many concurrent connections, but this is only true for the work loads I've tested with my specific data.
There are many variables at stake. The best thing you can do is benchmarking both varnish and squid against your content and in your environment and then choose the one that best suits your needs.