Mri*_*lla 4 python django caching
我正在使用Google的Firebug页面速度插件来分析我的Web应用程序的性能,其中之一就是我应该"利用缓存" - "以下可缓存资源的生命周期很短.指定到期时间至少一周在未来的以下资源".当我深入挖掘时,我发现对Django WSGI服务器的所有静态文件请求都缺少Expires和Cache-Control标头.谁应该添加这些标题 - Django应该这样做吗?如果是这样,怎么样?
谢谢.
您的页面可能具有的任何静态文件应由您的Web服务器提供,例如Apache.Django永远不应该参与,除非您必须阻止某些文件访问某些人.
在这里,我找到了一个如何做到的例子:
# our production setup includes a caching load balancer in front.
# we tell the load balancer to cache for 5 minutes.
# we can use the commented out lines to tell it to not cache,
# which is useful if we're updating.
<FilesMatch "\.(html|js|png|jpg|css)$">
ExpiresDefault "access plus 5 minutes"
ExpiresActive On
#Header unset cache-control:
#Header append cache-control: "no-cache, must-revalidate"
</FilesMatch>
Run Code Online (Sandbox Code Playgroud)