【问题标题】:How to minify CSS/JS with mod-pagespeed and Django?如何使用 mod-pagespeed 和 Django 缩小 CSS/JS?
【发布时间】:2012-07-08 11:15:49
【问题描述】:

刚刚在我的 django 实例上安装了最新版本的 mod-pagespeed 并尝试使用以下 pagespeed.conf 缩小 CSS/JS 但徒劳无功,即使 remove_cmets 和 collapse_whitespace 似乎可行。

ModPagespeedEnableFilters rewrite_javascript,rewrite_css,flatten_css_imports
ModPagespeedEnableFilters collapse_whitespace,elide_attributes
ModPagespeedEnableFilters combine_javascript,remove_comments

在 django 模板中,CSS/JS url 由 {{ STATIC_URL }}media/main.js 等指向,并且匹配的文件夹在 apache 设置中设置为别名,但 JS/CSS(及其链接)都没有改变。

我怀疑 mod-pagespeed 没有收到 js/css 由于模板引擎的干预..?

【问题讨论】:

    标签: django mod-pagespeed


    【解决方案1】:

    我终于找到了可以发挥作用的选项。

    # Explicitly tell mod_pagespeed to load some resources from disk.
    # This will speed up load time and update frequency.
    #
    # This should only be used for static resources which do not need
    # specific headers set or other processing by Apache.
    #
    # Both URL and filesystem path should specify directories and
    # filesystem path must be absolute (for now).
    #
    ModPagespeedLoadFromFile "http://example.com/static/" "/var/www/static/"
    

    注释掉 ModPagespeedLoadFromFile 并为您的 js/css 找到静态文件夹

    【讨论】:

      猜你喜欢
      • 2013-09-15
      • 1970-01-01
      • 2021-07-08
      • 2013-02-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多