Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I currently use nginx's proxy_cache for file-based caching in front of three Django applications (Apache/mod_wsgi). For some locations/URLs, I disabled proxy_cache and used Memcached (per view) within the Django app instead. Now I wonder whether pointing nginx to Memcached is more efficient.

I read here, that nginx can serve pages from Memcached – but does Django write complete pages to Memcached when configured for per view caching (and does it set an expiration date according to the @cache_page parameter)?

share|improve this question
up vote 1 down vote accepted

Using different applications to write to and read from the cache is always difficult even when there are are highly prescribed data formats/protocols. In this case, while both nginx and django can access memcached, it's very unlikely they will use the same data/indexing formats.

Reverse proxy caching is a very different beast from origin server caching. Realy it makes no sense to do any output caching at the application tier (it's often a good idea to do data caching here though). All the content which will be sent out via HTTP should be cached by nginx, and only by nginx. What substrate it uses for that is a different question.

share|improve this answer
So would it make sense to employ Memcached for Django (internally) instead of proxy caching by nginx? – janeden Apr 22 '13 at 13:12
No - I was trying to say the exact opposite of that - do your caching on nginx (typically around 70% or more of your bandwidth is used for static content - but it only takes a fraction of hardware capacity to do this via a reverse proxy compared with an origin webserver). – symcbean Apr 22 '13 at 13:26

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.