AWS_QUERYSTRING_AUTH = False not working with cached AWS S3 images of public S3 bucket

97 views Asked by At

I have a public AWS S3 bucket where I store mostly images for our site. I use boto3 to access and update images in the bucket.

Usually, I wrap my calls to images in my templates in sorl thumbnail tags like so:

{% thumbnail post.get_thumbnail_image.url '350x230' crop='center' as im %}
      <img src="{{ im.url }}" width="{{ im.width }}" height="{{ im.height }}"
                                 alt="{{ post.title }}">
{% endthumbnail %}

which results in the returned images looking like:

https://mybucket.s3.amazonaws.com/cache/e4/8f/e48f5547cec7e4a869696527fac12a8f.jpg

I now want to use Memcached to cache entire views on the website. I wouldn't think that would be a problem for a public bucket, because I don't expect the images requested to require a signature. Which is true once I set AWS_QUERYSTRING_AUTH = False in my settings.py - the images stop carrying signatures.

The problem is though that even for a public bucket with AWS_QUERYSTRING_AUTH = False, the thumbnail files I get back throw an Access Denied error when the signatures are removed.

Is this a matter of flushing some S3 cache somewhere? How can I make these cache thumbnail files respect my AWS_QUERYSTRING_AUTH = False?

0

There are 0 answers