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

CORS cloudfront/s3 caching #79

Open
jfabre opened this issue Apr 10, 2017 · 2 comments
Open

CORS cloudfront/s3 caching #79

jfabre opened this issue Apr 10, 2017 · 2 comments

Comments

@jfabre
Copy link
Contributor

jfabre commented Apr 10, 2017

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
Copy link
Owner

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
Copy link
Contributor Author

jfabre commented Apr 13, 2017

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

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

No branches or pull requests

2 participants