Where baby HTTP 404s come from

May 31, 2011

DISCLAIMER: I maintain the code that I refer to in this post, but I didn’t write the code.

I’ve been hunting HTTP 404 errors (that’s the “File Not Found” variety), and today I came across a bit of a puzzler. The non-existent image files were being referred to by a stylesheet as part of a CSS background: instruction, but the rule that contained the instruction was never invoked. That is, the rule was for a class name that was never used.

How the hell was I getting these image requests if the code that started the requests was never being used?

Then I noticed that the errors were coming from just a few different user agents. And they all had something about them…

See it? That’s right, they all come from mobile browsers. This puzzled me a bit, until I realised that it might be something you’d do to speed up the user experience if you knew they’d be on a slow connection (and you didn’t care if they downloaded heaps of data they didn’t need).

So here’s the piece of knowledge I want to add to the internet (he said, arrogantly assuming it wasn’t there already): Mobile browsers prefetch images from stylesheets as an optimisation in the face of low speed connections.

You’re welcome.

Where baby HTTP 404s come from - May 31, 2011 - Lucas Wilson-Richter