viewport-units-buggyfill icon indicating copy to clipboard operation
viewport-units-buggyfill copied to clipboard

CORS cloudfront/s3 caching

Open jfabre opened this issue 7 years ago • 2 comments

I've encountered an issue today where: 1- My first request to my css file on cloudfront (from head) would get cached. 2- The second (CORS) request to my css from this library would still get the same cached response even though there's a valid origin header in the request. 3- That would result in Safari denying the CORS because Cloudfront won't return the proper headers.

I hacked it by adding changing the url in the getCors function to:

url = url + "?rng=" Math.random()

It works like a charm in my case because I needed to make sure that the CORS request wouldn't receive a cached response.

Here's the issue I'm talking about: https://forums.aws.amazon.com/thread.jspa?messageID=555417&#555417 http://stackoverflow.com/questions/12498704/cached-non-cors-response-conflicts-with-new-cors-request

I would like to transform this issue into a PR, but I think it's best that I get your opinion on how you would want to implement the fix first.

Thanks.

jfabre avatar Apr 10 '17 03:04 jfabre

This should definitely be a configurable thing. importCrossOriginLinks() is the embedded utility that loads cross origin content automatically. I guess we could make initialize() accept an optional argument initOptions.loadCrossOriginContent which would be a function that has the same signature as getCors() and take over the loading entirely. This is the most flexible extension, as you're no longer limited to loading data via HTTP/S.

Does that sound reasonable to you?

rodneyrehm avatar Apr 10 '17 07:04 rodneyrehm

sounds good, I'll try to submit a PR this weekend.

jfabre avatar Apr 13 '17 23:04 jfabre