我正在尝试从 amazon s3 提供 gzip 文件。这是我的settings.py:
AWS_IS_GZIPPED = True
AWS_PRELOAD_METADATA = True
DEFAULT_FILE_STORAGE = 'storages.backends.s3boto.S3BotoStorage'
STATICFILES_STORAGE = 'storages.backends.s3boto.S3BotoStorage'
AWS_STORAGE_BUCKET_NAME = 'elasticbeanstalk-eu-west-1-2051565523'
STATIC_URL = 'https://%s.s3.amazonaws.com/' % AWS_STORAGE_BUCKET_NAME
COMPRESS_OFFLINE = True
COMPRESS_ENABLED = True
COMPRESS_URL = STATIC_URL
COMPRESS_CSS_FILTERS = [
'compressor.filters.css_default.CssAbsoluteFilter',
'compressor.filters.cssmin.CSSMinFilter'
]
COMPRESS_JS_FILTERS = [
'compressor.filters.jsmin.JSMinFilter',
]
COMPRESS_STORAGE = 'compressor.storage.GzipCompressorFileStorage'
当我这样做时,django 为每个 *.js 和 *.css 压缩创建 *.gz 文件,但奇怪的是只有 *.css 文件作为 gzip 提供。我可以在 aws s3 上看到 .css 文件具有 Content-Encoding: gzip 而 *.js 没有。这里发生了什么?