我正在做的是避免请求点击Django并直接从nginx提供缓存数据。
相关问题:Django staticgenerator vs CACHE_BACKEND
在这方面似乎有两种选择:
https://github.com/torchbox/django-nginx-memcache
https://github.com/mrj0/staticgenerator - 这个似乎更容易使用
尝试django-nginx-memcache后,我发现了一些缺点:
哪个更快?
你会使用哪一个?为什么?
我应该用 django-nginx-memcache 或 staticgenerator 来解决我的问题呢?
答案 0 :(得分:1)
这似乎回答了我的所有问题,提供了比 django-nginx-memcache 更优雅的解决方案,即修补django缓存系统:http://www.willmcgugan.com/blog/tech/2009/3/1/fast-caching-with-django-and-nginx/
静态内容几乎比使用nginx的memcache快4倍。
请求率:6243.8 req / s(0.2 ms / req)(静态html)
请求率:2285.5 req / s(0.4 ms / req)(在memcache中使用相同的html)
我想我会选择 staticgenerator ,但请随时发表您的想法。
我意识到我正在并行运行两个Web服务器,如果我选择 staticgenerator ,我需要一种方法来同步缓存的数据。我想我可以把它分叉并让它通过网络在两台服务器上写文件。有什么想法吗?
答案 1 :(得分:0)
您似乎想要缓存生成的页面。你试过Varnish(https://www.varnish-cache.org/)吗?
有时候我正在研究Django的缓存,我发现这篇文章关于使用Varnish缓存来缓存生成的页面。 http://ghughes.com/blog/2011/11/11/using-varnish-with-django-for-high-performance-caching/
可能适合你。
答案 2 :(得分:0)
本着保持简单的精神,如何在Nginx的代理模块中使用缓存指令?
与https://serverfault.com/a/68160/46143和http://www.rfxn.com/nginx-caching-proxy/
一致