Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Should I go with Varnish instead of nginx?

I really like nginx.

But recently I've found that varnish gives you an opportunity to implement smart caching revers proxy layer(with URL purging). I have a cluster of mongrels which are pretty resource-intensive so if this caching layer can remove some load from mongrels this can be a great thing.

I didn't find a way to implement the caching layer(with for application pages; static content is cacheable of course) same with nginx..

Should I use Varnish instead? What would you recommend?

like image 653
user80805 Avatar asked Jun 10 '10 16:06

user80805


People also ask

What is Varnish Nginx?

Varnish is a proxy server focused on HTTP caching. It's designed as HTTP accelerator and can act as reverse proxy for your web server Apache or Nginx. Varnish has been used for high-profile and high-traffic websites, including Wikipedia, The Guardian, and the New York Times.

Can Varnish Cache https?

To enforce HTTPS with Varnish Cache you will need to put an SSL/TLS terminator in front of Varnish Cache to convert HTTPS to HTTP. One way to do this is by using Nginx as the SSL/TLS terminator. Nginx is another reverse proxy that is sometimes used to cache content, but Varnish Cache is much faster.

What is difference between Redis and Varnish?

Varnish is a http accelerator which is used increase the speed of the site by caching the static contents. Redis server is a database server which stores frequently asked queries in the cache so users do not have to query the main database server.

What is Nginx FastCGI cache?

Nginx includes a FastCGI module which has directives for caching dynamic content that are served from the PHP backend. Setting this up removes the need for additional page caching solutions like reverse proxies (think Varnish) or application specific plugins.


1 Answers

I do not know what you mean under "smart", but anyway Nginx has caching starting from 0.7 branch. There are many parameters to tune, e.g.

  • you can have various TTLs for different return codes,
  • ability to return stale content when application does not respond
  • possible to limit the total size of the cache on disk
  • you can define what pieces of information will be used to generate a cache key.

The documentation is here

like image 64
Alexander Azarov Avatar answered Sep 20 '22 17:09

Alexander Azarov