【问题标题】:Can not access the static resource无法访问静态资源
【发布时间】:2012-11-05 12:32:25
【问题描述】:

我正在使用 Mezzanine、django-compressor 和 amazon-s3。我使用 django-compressor 来压缩 css 文件。我已经将网站部署到 Heroku 并成功存储了静态资源。但是,一段时间后,所有的CSS都丢失了。以下是来自 amazon-s3 的通知:

<Error>
<Code>AccessDenied</Code>
<Message>Request has expired</Message>
<RequestId>FCE5D863FC2EBB9D</RequestId>
<Expires>2012-11-16T17:30:01Z</Expires>
<HostId>
aXa9JBZWx5UiwJmIfpTXsUZgeNGQDONx0G/IezufvWv1FwAUlnK8bzo2u+Qdsenj
</HostId>
<ServerTime>2012-11-16T18:10:17Z</ServerTime>
</Error>

这是设置中的配置:

from datetime import date, timedelta
ten_years = date.today() + timedelta(days=365*10)
# Expires 10 years in the future at 23h GMT
AWS_HEADERS = {
    'Expires': ten_years.strftime('%a, %d %b %Y 23:00:00 GMT'),
    'Cache-Control': 'max-age=386900',
}

请帮我解决这个问题。我找不到根本原因。 非常感谢。

【问题讨论】:

    标签: django amazon-s3 django-cache django-compressor mezzanine


    【解决方案1】:

    这是因为访问签名的url。您可以在settings.py中进行以下设置来避免这种情况

    AWS_QUERYSTRING_AUTH = False
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-06-21
      • 2015-09-21
      • 2012-02-10
      • 2012-11-30
      相关资源
      最近更新 更多