WordPress.org

Ready to get started?Download WordPress

Forums

Handlng missing favicon.ico files wastes CPU time and slows WordPress (1 post)

  1. tigertech
    Member
    Posted 5 years ago #

    While measuring the CPU usage of several busy WordPress sites, I found something surprising: On some sites, 20–30% of the CPU time was being used to handle requests for missing "favicon.ico" files.

    The default WordPress permalink .htaccess rules tell index.php to handle requests for any missing file. If WordPress can't find a matching post or page, it displays a custom HTML error page (which can be quite CPU-intensive; on average, it seems to use about .3 seconds of CPU time on a 3 GHz Xeon on the sites I tested, and sites with lots of plugins use more).

    Unfortunately, WordPress handles "/favicon.ico" requests the same way, even though they aren't actually requests for HTML pages.

    My company hosts some WordPress sites that receive tens of thousands of requests per day for "/favicon.ico". Some of them didn't have a "favicon.ico" file, and the sites were spending thousands of CPU seconds per day generating HTML pages to send back to browsers that simply discard the results (because they requested an icon file, not an HTML page).

    We've solved this problem on our end, but there must be zillions of WordPress sites out there without a favicon.ico file that have the same problem, on small or large scales. CPU power is a finite resource, and wasting it slows down WordPress.

    To solve this, WordPress should ignore requests for "favicon.ico" (and perhaps "robots.txt"?) with additional rules in the .htaccess file:

    RewriteCond %{REQUEST_URI} !^/favicon.ico$

    (More background about this is in this blog post.)

    --
    Robert L Mathews, Tiger Technologies

Topic Closed

This topic has been closed to new replies.

About this Topic