views:

2077

answers:

2

I heard recently that Nginx has added caching to its reverse proxy feature. I looked around but couldn't find much info about it.

I want to set up Nginx as a caching reverse proxy in front of Apache/Django: to have Nginx proxy requests for some (but not all) dynamic pages to Apache, then cache the generated pages and serve subsequent requests for those pages from cache.

Ideally I'd want to invalidate cache in 2 ways:

  1. Set an expiration date on the cached item
  2. To explicitly invalidate the cached item. E.g. if my Django backend has updated certain data, I'd want to tell Nginx to invalidate the cache of the affected pages

Is it possible to set Nginx to do that? How?

+1  A: 

You can using memcached as cache engine and config NginxHttpMemcachedModule to perform caching base on URI as this link: http://www.igvita.com/2008/02/11/nginx-and-memcached-a-400-boost/

The backend Django should set/update the data (both static and dynamic) in memcached.

The problem with using the memcached module is that I can't put the cached pages on disk, which I'd like to do
Continuation
For persisten memcached, you can use Tugela Cache, memcachedb with the same protocol.For squid-style, you can use ncache from http://code.google.com/p/ncache/ but it not relate to programming :D
+1  A: 

Info for invalidation proxy cache: http://linux-sysadmin.org/2010/08/nginx-invalidation-purging-content/

Derek