mozilla / addons

☂ Umbrella repository for Mozilla Addons ✨
Other
127 stars 41 forks source link

Make xpi download URL app-less and add specific CDN behavior for it #1871

Open diox opened 2 years ago

diox commented 2 years ago

Our download URLs look like this: https://{domain}/{app}/downloads/file/{id}/{filename.xpi}. Which means poor cache hit ratio, because /android/ and /firefox/ are considered different, but also because it's using the default CDN policy, which means their cache key depends on a lot of different things.

We should make the URL app-less and add in the CDN config a specific behavior for that pattern, removing User-Agent, Accept-Language, DNT from the cache key settings.

A couple gotchas to consider:

┆Issue is synchronized with this Jira Task

diox commented 2 years ago

This might block https://github.com/mozilla/addons/issues/8725. See also https://github.com/mozilla/addons/issues/8732

diox commented 2 years ago

Old URL with the app would need to continue to work... we used to redirect in the other way around (no app redirects to with app) so that might cause infinite redirects depending on what got cached.

Given this results in a 301 with a super long Cache-Control: max-age= value we should probably support both separately and don't try to redirect.

diox commented 2 years ago

We could start by not consolidating the /android/ and /firefox/ paths into one and focus on tackling the CDN behavior instead. That would likely mean having the 2 patterns separate in the CDN config:

Less effective, but that should already improve things a bit.

KevinMind commented 6 months ago

Old Jira Ticket: https://mozilla-hub.atlassian.net/browse/ADDSRV-87

diox commented 2 months ago

This is still valuable - it would improve our cache hit ratio, therefore consuming less bandwidth - but we should wait until we've switched away from CloudFront.