2012-06-11 52 views
0

剛剛在我的django實例上安裝了最新版本的mod-pagespeed,並試圖用以下pagespeed.conf來縮小CSS/JS,但徒勞無功,儘管remove_comments和collapse_whitespace似乎可以解決。如何用mod-pagespeed和Django來縮小CSS/JS?

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

在Django模板,CSS/JS URL指出由{{STATIC_URL}}媒體/ main.js等以及匹配文件夾被設置爲在Apache的設置的別名,但JS/CSS(和它的鏈接)完全沒有變化。

我懷疑由於模板引擎的介入,mod-pagespeed沒有選擇js/css。

回答

0

我只是終於找出了會有所作爲的選擇。

# 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