A client of Jim's with a WordPress site had been having performance issues that were off the scale bad. Slower then a snail on Valium. Slower than a herd of turtles rampaging through a molasses factory. Worse than that, the actual in-browser rendering was taking significantly longer than any benchmarking tests would lead you to believe. Even massively loaded benchmark tests had a better rendering time. And the client's browser's weren't massively loaded.

After investigating a number of avenues, Jim decided to migrate the site to newer, faster infrastructure. The older machines were due for a refresh anyway. And the newer infrastructure would be on Ubuntu Precise, whereas the older was Lucid. So, as a bonus, the client got a free upgrade! Free as in beer.

While using wget to pre-populate the caching system on the new infrastructure, Jim ran into a segfault error. Huh? Segfault from wget? Why would a really, really old and stable CLI utility throw a segfault while reading the site? The logs seem like a logical place to start the search and, as expected, an odd entry was found.

GET /[redacted]/[redacted]/%E2%80%9Dhttp:/ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js%E2%80%9D HTTP/1.1 404

Oddness abounds. Because, so far as Jim knows, there shouldn't be a reference that looks like that in the code. So, he began to grep through the source. No reference to Google APIs is found. Next, he dumps the database and greps the contexts. Still no Google API URL to be found. But he did notice that there were references to seven different versions of jQuery being referenced by the various plugins, theme snippets and templates. So the search was changed to look specifically for calls that included version 1.5.

Turns out there was only one, in a header file. And it appeared to be perfectly normal.

<script src=”http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js”></script>

Staring at a line of code is not traditionally taught as a debugging technique. However, in this case, it was effective. Close scrutiny reveals that the src attribute's value is surrounded in smart quotes.

And, as a result of these so-called "smart" quotes, all modern browsers (including, thankfully, wget) would attempt to grab the source code from http://[currentURL]/%E2%80%9Dhttp:/ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js%E2%80%9D.

Now, in most instances, this would be merely annoying. But for the site that Jim's client had, it used mod_redirect to parse incoming URLs. As a result, it was not a quick, simple HTTP status 404 that was returned. It was a full, completely uncachable page rendering, which ultimately resulted in a 404. Since the request was bypassing the proxy tier's caching, the page cache and, effectively, the object cache, it was adding between 800-4000ms to every, single request. Every. Single. Request.

As you might imagine, the correction greatly improved the overall speed of the site.

When many of us go searching for the solution to the most recent problem that we're trying to solve, our first, last and only resource is frequently the Interwebs. And when we find that elusive example that does exactly what we need it to do, we cut and paste with blind abandon. Emphasis on the 'blind'. Yes, the collective wisdom of the ages is available on-line, easily within our grasp. But applying that wisdom without understanding is dangerous. Even if 'understanding' consists of little more that recognizing certain types of quotes.