djangodjango-storage

django-storage with s3-boto break browser cache


I have a django project which use django-storage over s3-boto.

Problem is that every file that is located on S3 unable to cache because the url is changed from each call.

here are two calls generated by django-storage :

https://my.s3.amazonaws.com/cache/user_6/profile_pic/profile_profile_picture_thumbnail.jpg?Signature=HlVSayUIJj6dMyk%2F4KBtFlz0uJs%3D&Expires=1364418058&AWSAccessKeyId=[awsaccesskey]     
https://my.s3.amazonaws.com/cache/user_6/profile_pic/profile_profile_picture_thumbnail.jpg?Signature=xh2VxKys0pkq7yHpbJmH000wkwg%3D&Expires=1364418110&AWSAccessKeyId=[awsaccesskey]

As you can see the signature is different. What can I do so it wont break my browser cache ?


Solution

  • In your settings, just add the following:

    AWS_QUERYSTRING_AUTH = False
    

    This will make sure that the URLs to the files are generated WITHOUT the extra parameters. Your URLs would look like:

    https://my.s3.amazonaws.com/cache/user_6/profile_pic/profile_profile_picture_thumbnail.jpg