What I'm doing is avoiding having requests hit Django and serving cached data straight from nginx.
Related question: Django staticgenerator vs CACHE_BACKEND
There seem to be two choices when it comes to this:
https://github.com/torchbox/django-nginx-memcache
https://github.com/mrj0/staticgenerator - This one seems easier to use
After trying django-nginx-memcache I found some downsides:
- No fallback to serve cached content from django (can be fixed).
- nginx has to be recompiled for md5 sum generation of urls (I don't think this can be fixed).
- Edit: After looking at other solutions (such as: http://soyrex.com/articles/django-nginx-memcached/) I find that there seems no need to use md5 cache_keys. Maybe this should be an option.
- It would be nice to be able to define a list of url patters that should be cached. So far, only decorators are available (can be fixed).
- The code should in my opinion be modelled more after the standard django cache backend with UpdateCacheMiddleware and FetchFromCacheMiddleware. This would make it easier to implement nginx cache where standard django cache solutions exist. It would also solve problem #1 (can be fixed).
- Strange naming of module. While the project is named django-nginx-memcache, the package is named Django-Memcache-for-Nginx and the app nginx_memcache for inclusion in django installed_apps (can be fixed).
Which is faster?
Which one would you use and why?
Should I fix the issues that I have with django-nginx-memcache or is staticgenerator just better anyway?