Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Cache-Control header support for Azure backend #780

Merged
merged 2 commits into from Nov 18, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 6 additions & 0 deletions docs/backends/azure.rst
Expand Up @@ -159,3 +159,9 @@ The following settings are available:

A token credential used to authenticate HTTPS requests. The token value
should be updated before its expiration.


``AZURE_CACHE_CONTROL``

A variable to set the Cache-Control HTTP response header. E.g.
``AZURE_CACHE_CONTROL = "public,max-age=31536000,immutable"``
4 changes: 3 additions & 1 deletion storages/backends/azure_storage.py
Expand Up @@ -134,6 +134,7 @@ class AzureStorage(Storage):
overwrite_files = setting('AZURE_OVERWRITE_FILES', False)
location = setting('AZURE_LOCATION', '')
default_content_type = 'application/octet-stream'
cache_control = setting("AZURE_CACHE_CONTROL")
is_emulated = setting('AZURE_EMULATED_MODE', False)
endpoint_suffix = setting('AZURE_ENDPOINT_SUFFIX')
sas_token = setting('AZURE_SAS_TOKEN')
Expand Down Expand Up @@ -255,7 +256,8 @@ def _save(self, name, content):
stream=content,
content_settings=ContentSettings(
content_type=content_type,
content_encoding=content_encoding),
content_encoding=content_encoding,
cache_control=self.cache_control),
max_connections=self.upload_max_conn,
timeout=self.timeout)
return cleaned_name
Expand Down
3 changes: 2 additions & 1 deletion tests/test_azure.py
Expand Up @@ -304,7 +304,8 @@ def test_storage_save(self):
timeout=20)
c_mocked.assert_called_once_with(
content_type='text/plain',
content_encoding=None)
content_encoding=None,
cache_control=None)

def test_storage_open_write(self):
"""
Expand Down