Saturday 25 February 2012

Asynchronous HTTP GETs being slow

Note to self:

If asynchronous HTTPS GETs from the same browser (in multiple tabs, say, or from an ajax site) seem slower than they should be - for example, if request roundtrip times get multiplied up by the number of tabs open - then it's very likely a bottleneck being caused by the browser cache. Firefox and Chrome at least (not tested any others) seem to only allow cache writing through a critical section or something. So the entire browser has a single, locked cache. And seems to lock it for the *entire* duration of the GET request. Which means aysnchronous GETs end up forming an orderly but very slow queue.

Turn off caching in the http request object and the problem goes away (though, of course, you don't get to cache anything any more).

Came as a surprise to me. Couldn't find an explanation for the behaviour when it cropped up - I assumed for ages our server was to blame. It wasn't.

2 comments:

MartinSz said...

I was wondering if you've re-tested in the almost-2-years since your post. It would be valuable to know if this situation remains the same or has been addressed by the browsers...?

Throctukes said...

I haven't, I'm afraid.