Question

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?

Was it helpful?

Solution

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

OTHER TIPS

Nginx has some nice features if you just need very basic caching, but Varnish lets you do active purges by URL or header matching, edge side includes so different parts of your pages can have different TTLs, and lots of other trickery because it has a very flexible configuration language.

If you really want to seriously cache and reduce load on your backends, I'd go with varnish, but it's going to be a lot more work to set up than just adding a few directives to your nginx.conf.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top