diff --git a/docs/index.rst b/docs/index.rst index a95768c..c6f49d9 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -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 diff --git a/flask_s3.py b/flask_s3.py index 043dbdb..5d41436 100644 --- a/flask_s3.py +++ b/flask_s3.py @@ -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