我可以gzip JavaScript和CSS文件在Django吗? [英] Can I gzip JavaScript and CSS files in Django?

查看:229
本文介绍了我可以gzip JavaScript和CSS文件在Django吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图剖析我的web应用程序,报告的瓶颈之一是缺乏gzip压缩。我继续在Django中安装gzip中间件,并得到一点提振,但一个新的报告显示,它只是压缩HTML文件,即任何由Django处理的内容。有没有办法我可以kludge / hack / force /使中间件gzip我的CSS和我的JS?

I tried profiling my web application and one of the bottlenecks reported was the lack of gzip compression. I proceeded to install the gzip middleware in Django and got a bit of a boost but a new report shows that it is only gzipping the HTML files i.e. any content processed by Django. Is there a way I could kludge/hack/force/make the middleware gzip my CSS and my JS as well?

有人可以回答我的问题。

Could someone please answer my questions below. I've gotten a little lost with this.


  • 我可能会错了,但
    的人会gzip CSS和JS,
    不是吗?

  • Django不压缩
    JS和CSS浏览器的
    兼容性问题?

感谢。 p>

Thanks.

推荐答案

感谢大家。

看来Django中的GzipMiddleware DOES 会压缩CSS和JS。

It seems that the GzipMiddleware in Django DOES compress CSS and JS.

我使用Google的Page Speed插件来为Firebug配置我的页面,似乎它正在生成基于CSS的旧副本(非gzip版本)的报告, JSs在我的本地缓存。这些副本是从我启用Gzip中间件之前的时间。我刷新缓存,似乎报告显示不同的结果。

I was using Google's Page Speed plugin for Firebug to profile my page and it seems that it was generating reports based on old copies (non-gzipped versions) of the CSSs and JSs in my local cache. These copies were there from the time before I enabled the Gzip middleware. I flushed the cache and it seems that the reports showed different results altogether.

这篇关于我可以gzip JavaScript和CSS文件在Django吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆