Skip to content

Commit

Permalink
Fixed cache control. Added cache_control to settings.
Browse files Browse the repository at this point in the history
  • Loading branch information
bodja committed Mar 9, 2016
1 parent f95c605 commit aa4ca38
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
4 changes: 3 additions & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,15 @@ Settings
'bucket': None,
'project': '',
'credentials': None,
'http': None
'http': None,
'cache_control': ['no-cache']
}
* ``bucket`` name of the bucket on google cloud storage.
* ``project`` google project name (not required).
* ``credentials`` oauth2 credentials
* ``http`` httplib2.Http instance or callable that returns httplib2.Http instance
* ``cache_control`` is a list of strings. By default ['no-cache']

*Note: One of* ``credentials`` *or* ``http`` *should be provided for authentication.*

Expand Down
3 changes: 2 additions & 1 deletion django_gcs/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
'bucket': None,
'project': '',
'credentials': None,
'http': None
'http': None,
'cache_control': ['no-cache']
}


Expand Down
5 changes: 4 additions & 1 deletion django_gcs/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,11 @@ def _save(self, name, content):
content_type = content.content_type
else:
content_type = mimetypes.guess_type(name)[0]
blob.cache_control = settings.GOOGLE_CLOUD_STORAGE.get('cache_control')
blob.upload_from_file(content, True, content.size, content_type)

blob.cache_control = ', '.join(settings['cache_control'])
blob.patch() # submit cache_control

blob.make_public()
return name

Expand Down

0 comments on commit aa4ca38

Please sign in to comment.