我使用的Django-COM pressor和Django的储量为我的COM pressed在S3上的文件(使用这些指令:http://django_com$p$pssor.readthedocs.org/en/latest/remote-storages/#using-staticfiles).它的伟大工程运行的COM preSS管理命令开始后,但约一小时后,COM pressed CSS和JS文件返回尽管我还没有做出任何更改文件403 Forbidden错误。我似乎无法找出问题所在,所以任何帮助,将AP preciated。
I'm using django-compressor and django-storages to serve my compressed files on S3 (using these instructions: http://django_compressor.readthedocs.org/en/latest/remote-storages/#using-staticfiles). It works great initially after running the "compress" management command, but after about one hour the compressed css and js files return a 403 Forbidden error even though I haven't made any changes to the files. I can't seem to isolate the problem, so any help would be appreciated.
下面是我使用的设置:
COMPRESS_ENABLED = True
COMPRESS_URL = "http://mybucket.s3.amazonaws.com/"
COMPRESS_STORAGE = 'sm.storage.CachedS3BotoStorage'
COMPRESS_YUI_BINARY = os.path.join(PROJECT_ROOT, 'jars/yuicompressor-2.4.7.jar')
COMPRESS_CSS_FILTERS = ['compressor.filters.yui.YUICSSFilter',
'compressor.filters.css_default.CssAbsoluteFilter']
COMPRESS_JS_FILTERS = ['compressor.filters.yui.YUIJSFilter',]
COMPRESS_OFFLINE = True
STATICFILES_STORAGE = COMPRESS_STORAGE
STATIC_URL = COMPRESS_URL
STATIC_ROOT = '/path/to/static/'
STATICFILES_DIRS = (
os.path.join(PROJECT_ROOT, 'static'),
)
DEFAULT_FILE_STORAGE = 'storages.backends.s3boto.S3BotoStorage' # I'm using this for uploaded media
AWS_ACCESS_KEY_ID = 'myaccesskey'
AWS_SECRET_ACCESS_KEY = 'mysecretkey'
AWS_STORAGE_BUCKET_NAME = 'mybucket'
AWS_S3_FILE_OVERWRITE = True
AWS_HEADERS = {
'Cache-Control': 'public, max-age=31536000', #(1 year)
}
更新:这只是似乎是一个问题,当COM preSS_OFFLINE为True。我将它设置为初始请求期间创建的虚假和COM pressed文件是否正常工作,并已经过了一个小时。不过,我想preFER至pre COM preSS使用管理命令这些文件。
UPDATE: This only seems to be a problem when COMPRESS_OFFLINE is True. I set it to False and the compressed files that were created during the initial request are working correctly and it has been over an hour. However, I would prefer to pre compress these files using the management command.
我能够加入这一行我的设置文件,以解决此问题:
I was able to resolve this problem by adding this line to my settings file:
AWS_QUERYSTRING_AUTH = False
幸得 blackrobot。
Credit goes to blackrobot on github.