Quick WordPress Performance Tip: Create a favicon
One of our members’ WordPress blogs got heavily FARKed a bit ago. Alarms went off, we thought the server was going to crash. That’s pretty unusual, of course, so we looked into it and found something really interesting: the blog’s performance problem was entirely caused by the lack of a favicon.ico file.
To quote Adrian Monk: “Here’s what happened…”
WordPress uses a handful of rewrite rules to present “pretty URLs” to visitors:
RewriteCond %{REQUEST_FILENAME} -f [OR] RewriteCond %{REQUEST_FILENAME} -d RewriteRule ^(.+) - [PT,L] RewriteRule ^(.*) index.php
What this does is that if the file or directory the visitor is asking for doesn’t exist in the site’s filesystem (as blog entries do not), it pushes the request into the WordPress engine to be handled. WordPress doesn’t do very well when asked to serve things that do not exist. There are a lot of things that a particular link could be, and it has to check them all before finally erroring out.
Since favicon.ico doesn’t exist but gets requested at least once by everyone who even thinks about visiting the site, it was causing a huge amount of server load to generate all these 404 pages that nobody would ever see.
With the site owner’s permission, we created a zero-length favicon.ico file in the site’s public directory until they could make one themselves, and the problem immediately went away. The change was so immediately and so profound that we felt compelled to blog about it.
While this happened on WordPress, it’s worth remembering for any application or custom code that drives every incoming request into a PHP or CGI handler. Everybody who visits your site (and some people who don’t) will request /favicon.ico, so make sure you know what happens when they do.
Preferably before FARK and company get ahold of it! 🙂
5 Comments
RSS feed for comments on this post.
Sorry, the comment form is closed at this time.
Entries and comments feeds.
Valid XHTML and CSS.
Powered by WordPress. Hosted by NearlyFreeSpeech.NET.
Same thing goes for robots.txt and favicon.gif, by the way. 🙂
http://www.dreamhoststatus.com/2009/06/10/faviconico-favicongif-and-robotstxt-update/
Comment by A Competitor — June 17, 2009 #
Thanks for the feedback, Mr. Competitor. And we’re flattered by the attention. 🙂
Auto-creating empty favicon.ico files sounds like an idea with potential, at least for new sites. We’ll definitely take a look at that. Thanks for the suggestion!
On favicon.gif, people can certainly create one if they want. We show about a 160:1 ratio of favicon.ico 404’s to favicon.gif, so we’re confident our servers can take the heat there. 🙂
Robots.txt, on the other hand, does get hit pretty hard (about 4:1 favicon:robots), but one rogue search engine (at a time) doesn’t create the same access pattern as an Internet mob clamoring for info about the techno-adventures of geek girls. Nothing does, really. 🙂
Judging by some of the comments in the link you provided, blank robots.txt files popping up all over the place can adversely affect people who are dynamically generating them, which makes them sad. So, while people definitely should consider creating one, our servers will just have to continue to tough it out if they don’t. 🙂
Thanks again for stopping by. You’re welcome anytime, especially if you’re bringing good food for thought. Mmm, food… gotta go.
-jdw
Comment by jdw — June 17, 2009 #
That’s why the merb framework auto creates a zero length favicon too on new projects. Save a trip through the framework. Ever since seeing that I make sure I have a favicon.ico 🙂
Comment by Nicholas Orr — June 18, 2009 #
Hmmm, this is good to know. I shall henceforth update all of my sites with blank favicon.gif and robots.txt files if needed. If nothing else, they serve as reminders to do more with them.
Comment by Crafty Hunter — June 21, 2009 #
[…] information…” box if our system detects potential problems with your site, ranging from missing favicon.ico files to insecure “public” directory […]
Pingback by NearlyFreeSpeech.NET Blog » Small member interface upgrades — June 21, 2009 #