rodneyrehm / viewport-units-buggyfill

Making viewport units (vh|vw|vmin|vmax) work properly in Mobile Safari.
MIT License
1.59k stars 151 forks source link

CORS cloudfront/s3 caching #79

Open jfabre opened 7 years ago

jfabre commented 7 years ago

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.

rodneyrehm commented 7 years ago

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?

jfabre commented 7 years ago

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