【发布时间】:2014-09-27 00:35:32
【问题描述】:
我已经成功地使用django-compressor 和django-storages 在 Django 1.6 中管理我的静态文件的压缩和部署。我现在正在尝试使用 AWS CloudFront 来提供我的静态文件。
我按照default_storage.exists extremely slow and frequently times out 此处的说明进行操作,我的settings.py 文件如下所示:
COMPRESS_ENABLED = True
STATIC_ROOT = os.path.join(
os.path.dirname(
os.path.dirname(
os.path.abspath(__file__))), 'static')
COMPRESS_ROOT = STATIC_ROOT
COMPRESS_OFFLINE = True
COMPRESS_URL = "https://compressor-test.s3.amazonaws.com/"
STATIC_URL = COMPRESS_URL
COMPRESS_STORAGE = 'mysite.storage.CachedS3BotoStorage'
STATICFILES_STORAGE = COMPRESS_STORAGE
AWS_STORAGE_BUCKET_NAME = 'compressor-test'
AWS_S3_CUSTOM_DOMAIN = '1234567.cloudfront.net'
但我收到以下错误:
Exception Type: UncompressableFileError
Exception Value:
'https://1234567.cloudfront.net/bootstrap/css/bootstrap.min.css' isn't accessible via COMPRESS_URL ('https://compressor-test.s3.amazonaws.com/') and can't be compressed
我需要将 COMPRESS_URL 指向 CloudFront 吗?
【问题讨论】:
-
你可以手动访问文件吗?
-
是的,如果我将完整的 url 粘贴到地址栏中,它会打开正确的文件。
-
我不记得为什么了,但我现在记得这个问题之前在 stackoverflow 中被问过。你可以重新搜索。
标签: django boto amazon-cloudfront django-storage django-compressor