AWS S3网址动态变化的Django的静 [英] AWS S3 Url changing dynamically with django statics
问题描述
当我从AWS S3提供静态文件使用{%静态%}模板,我得到这个类型的URL: <一href="https://elasticbeanstalk-eu-west-1-2548513.s3.amazonaws.com/css/7aa4edf0c543.css?Signature=lpSpJuyv55JwkjxGKnNVmfn5QKs%3D&Expires=1370880855&AWSAccessKeyId=AKIAIDOQ45S6OQCXGNYQ" rel="nofollow">https://elasticbeanstalk-eu-west-1-2548513.s3.amazonaws.com/css/7aa4edf0c543.css?Signature=lpSpJuyv55JwkjxGKnNVmfn5QKs%3D&Expires=1370880855&AWSAccessKeyId=AKIAIDOQ45S6OQCXGNYQ
When I am serving static files from AWS S3 using the {%static %} template I get this type of url: https://elasticbeanstalk-eu-west-1-2548513.s3.amazonaws.com/css/7aa4edf0c543.css?Signature=lpSpJuyv55JwkjxGKnNVmfn5QKs%3D&Expires=1370880855&AWSAccessKeyId=AKIAIDOQ45S6OQCXGNYQ
好了签名每次变化。所以,当我使用django_storages离线COM pression的关键该文件正在改变,因为每次它的名字被改变,所以我得到的错误: 您已启用脱机COM pression但关键的4c18774209c3d10bb81ec7f466b17e21从线下明显缺失。您可能需要运行蟒蛇manage.py COM preSS。
Well the signature changes everytime. So when I am using django_storages with offline compression the key for that file is changing everytime because its name is changing so I get the error: You have offline compression enabled but key "4c18774209c3d10bb81ec7f466b17e21" is missing from offline manifest. You may need to run "python manage.py compress".
而不是使用{%静态%}模板,如果我用一个恒定的URL这个错误不会发生。
If instead of using the {%static %} template I use a constant URL this error doesn't happens..
为什么AWS的S3有那种网址?请告诉我签名的点和过期参数?我改变了我的AWS S3的配置来发送Expires头和Cache-Control 1年,但是从到期的网址只有一个小时。
Why does the aws s3 has that kind of URL ? Whats the point of the signature and the Expires parameters? I changed my aws s3 configuration to send expires header and cache-control for 1 year, however the expires from the url is just one hour.
推荐答案
尝试添加到您的设置。
应该停止GET参数添加到URL。
It should stop the get params being added to the url.
AWS_QUERYSTRING_AUTH = False
这篇关于AWS S3网址动态变化的Django的静的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!