codefrau / SqueakJS

A Squeak Smalltalk VM in Javascript
https://squeak.js.org
MIT License
371 stars 76 forks source link

SocketPlugin: keep CORS flag per server #63

Closed codefrau closed 8 years ago

codefrau commented 8 years ago

Currently we always try a direct request first, and the proxied one second. In some situations this leads to considerable delay (e.g. 2 seconds on source.squeak.org).

We might want to keep a table of hosts and their need-proxy flag. Whenever a request succeeds we put a flag for that host in the table. When another request comes in and we have a flag already then we use the order (proxy/direct first) given by the flag, otherwise we try direct first.

fniephaus commented 8 years ago

Wouldn't it be better if we check the URL if a proxy is needed in the first place?

codefrau commented 8 years ago

There is no way to know in advance if a server is CORS-enabled or not, you can only try. We do not want to use the proxy unless it is necessary.

fniephaus commented 8 years ago

True, and keeping track of URLs as suggested here would certainly speed up requests. I'm happy to take care of this...