所以我使用'django-compressor'来压缩所有的css文件。它确实将所有 css 文件缩小并合并为一个文件“9756d9abb2c2.css”,但这个文件的大小几乎等于所有 css 文件的总和。Google PageSpeed 仍然告诉我:
Compressing http://xxx/9756d9abb2c2.css could save 85.1KiB (87% reduction).
我不确定可能是什么问题:/
编辑:这是我的设置:
DEBUG = True
STATIC_ROOT = ''
STATIC_URL = '/stic/'
STATICFILES_DIRS = (
'static',
)
COMPRESS_OFFLINE_CONTEXT = {
'STATIC_URL': '/stic/',
}
COMPRESS_ENABLED = True
COMPRESS_OUTPUT_DIR = 'static/CACHE'
STATICFILES_FINDERS = (
'django.contrib.staticfiles.finders.FileSystemFinder',
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
'compressor.finders.CompressorFinder', # compressor (compress css and js files)
)
MIDDLEWARE_CLASSES = (
####...
'django.middleware.gzip.GZipMiddleware', #enable gzip compression for html
)