Posts from December 2009

Wag.gd - short URLs with a point

Short URLs are a bit of a hot-button topic amongst devs - some think they're useful (like Russell), some are wary of them (like me) and some, like my friend Simon, rail against them as a waste of time and resource.

Simon, however, is a sensible sort so rather than just making lots of noise about how they suck, he's gone away and tried to think of a sensible use case, then implemented it.

So take a look over at Wag.gd if you're interested in mobile development. Simon's written about it far better than I could and it's certainly an interesting idea.

Why you should close PHP sessions as soon as you can

When serving files with PHP, you may notice a curious effect where only one request gets served at a time per user.

You can see it if you're the kind of retro throwback who uses framesets served via PHP - the panels will load in one at a time. You'll see the same thing if you generate a load of images via PHP - they'll pop up sequentially - and if you serve large video files via PHP like we do at work you may see a curious effect of the downloads queueing up. Those of you with AJAX applications may be victim to this without realising, but if you're serving JSON/XML responses from PHP scripts you'll find that your parallel AJAX requests will only get served one at a time.

I've seen this effect a few times and always ended up working around it. The odd thing is this isn't a setting in Apache or a global slowdown of your server. PHP just refuses to serve more than one request per user at a time. Luckily Kevin managed to spot the reason, and it was a new one on me even after 9+ years of using PHP (it's possible everyone else knows about it, mind you).

The answer is pretty simple: PHP can only handle one response at a time if you have an open session.