There are many ways to lose at CORS and this one is my story.
There are many ways to lose at CORS and this one is my story.
Getting Vary right isn't just important for Chrome, it's important for CDNs too.
Hmm, I think I'll add a section to the article on this when I'm back at my laptop.
Thanks for prompting this!
S3 is used as an example, as it does not include a Vary header for non-CORS requests. However, the same would be true of some other origin which isn't correctly inserting a Vary header.
For us it got triggered because an image on the site appeared both as a video "poster" attribute (which loads with CORS) and as a regular image. So depending on which image the user encountered first you would see a CORS error. But it would be gone after a reload, so devilishly hard to reproduce until you realise what's happening.
Also took me ages to figure out that Cloudfront didn't include the Origin in the Vary header if it wasn't in the original request.
(@jaffathecake perhaps that Cloudfront behaviour warrants a special mention. Great article by the way, I learned a lot)
Incidentally, while you're here, I'm planning on building something which will require use of SharedArrayBuffer. Will adding the (now) required Cross-Origin isolation COOP/COEP headers cause any issues to existing CORS setups?
:)