Updates issue #7 - Set old S3_CACHE_CONTROL in S3_HEADERS on init and

doc fixes.
This commit is contained in:
Hannes Ljungberg
2013-06-11 01:38:03 +02:00
parent 8c0eff3f97
commit 30190f7715
2 changed files with 6 additions and 13 deletions
+3 -9
View File
@@ -152,9 +152,9 @@ headers you want to use with the `S3_HEADERS` option.
'Cache-Control': 'max-age=86400',
}
See `yahoo`_ more information on how to set good values for your headers.
See `Yahoo!`_ more information on how to set good values for your headers.
.. _yahoo: http://developer.yahoo.com/performance/rules.html#expires
.. _Yahoo!: http://developer.yahoo.com/performance/rules.html#expires
.. _settings:
.. _configuration:
@@ -198,14 +198,8 @@ uploading assets to S3.
specified by `flask.url_for`.
`S3_HEADERS` Sets custom headers to be sent with each file to S3.
**Default:** `{}`
`S3_CACHE_CONTROL` **Deprecated**. Please use `S3_HEADERS` instead.
This sets the value of the Cache-Control header that
is set in the metadata when `S3_USE_CACHE_CONTRL` is
set to `True`.
`S3_CACHE_CONTROL` **Deprecated**. Please use `S3_HEADERS` instead.
`S3_USE_CACHE_CONTROL` **Deprecated**. Please use `S3_HEADERS` instead.
Specifies whether or not to set the metadata for the
Cache-Control headers.
**Default:** `False`
=========================== ===================================================
.. _debug: http://flask.pocoo.org/docs/config/#configuration-basics
+3 -4
View File
@@ -107,9 +107,6 @@ def _write_files(app, static_url_loc, static_folder, files, bucket,
logger.debug("%s excluded from upload" % key_name)
else:
k = Key(bucket=bucket, name=key_name)
if (app.config['S3_USE_CACHE_CONTROL'] and
'S3_CACHE_CONTROL' in app.config):
k.set_metadata('Cache-Control', app.config['S3_CACHE_CONTROL'])
# Set custom headers
for header, value in app.config['S3_HEADERS'].iteritems():
k.set_metadata(header, value)
@@ -229,4 +226,6 @@ class FlaskS3(object):
if app.config['USE_S3']:
app.jinja_env.globals['url_for'] = url_for
if 'S3_USE_CACHE_CONTROL' and 'S3_CACHE_CONTROL' in app.config:
cache_control_header = app.config['S3_CACHE_CONTROL']
app.config['S3_HEADERS']['Cache-Control'] = cache_control_header