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

Improve cache times of GCS-hosted images #210

Open
stevejalim opened this issue Nov 7, 2023 · 4 comments
Open

Improve cache times of GCS-hosted images #210

stevejalim opened this issue Nov 7, 2023 · 4 comments
Assignees

Comments

@stevejalim
Copy link
Collaborator

stevejalim commented Nov 7, 2023

Wagtail stores user media in a GCS bucket, and pages load those assets directly from the bucket.

I've just noticed that the max-age for the Cache-control header is 1hr.

It would be good to increase this. I don't think there's a downside of a high TTL: if someone uploads a file with the same filename, the settings will ensure that the new file has a different filename to an existing one.

@stevejalim stevejalim converted this from a draft issue Nov 7, 2023
@stevejalim
Copy link
Collaborator Author

I think we can do this via settings for django-storages, so no SRE magic needed, but just ccing you @bkochendorfer because I know how much you love cache-control :)

@stevejalim stevejalim moved this from Prioritized backlog to In Progress in Birdbox Dec 5, 2023
@stevejalim
Copy link
Collaborator Author

Heya @bkochendorfer - here's an interesting (and non-critical) one...

Looking at this, the images in GCS are coning back with cache-control: public, max-age=3600

But in theory when we upload them we are setting:

GS_OBJECT_PARAMETERS = {
    "cache_control": "max-age=2592000, public, immutable",
    # 2592000 == 30 days 1 month age
}

and the cache_control key looks right compared to the docs

Any chance there is something going on at GCS (or at the CDN layer for when the origin is GCS) please?

@stevejalim stevejalim self-assigned this Dec 5, 2023
@bkochendorfer
Copy link
Member

Can you provide an example URL for me to investigate?

@stevejalim
Copy link
Collaborator Author

@bkochendorfer D'oh that would have been useful for me to do, yeah.

https://storage.googleapis.com/future-prod-prod-storage/images/ai.original.svg is an example of a GCS-held image where the cache time isn't what we're expecting. No super rush to look at this. Thanks, dude!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: In Progress
Development

No branches or pull requests

2 participants