0

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)?

janeden
  • 237
  • 2
  • 6

1 Answers1

1

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.

symcbean
  • 21,009
  • 1
  • 31
  • 52
  • 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