How to set up Nginx as a caching reverse proxy?

Posted by Continuation on Server Fault See other posts from Server Fault or by Continuation
Published on 2009-06-24T01:35:45Z Indexed on 2010/03/13 18:05 UTC
Read the original article Hit count: 215

Filed under:
|
|
|

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?

© Server Fault or respective owner

Related posts about nginx

Related posts about reverse-proxy