Increase WordPress performance on IIS

I noticed that the Time To First Byte (TTFB) of my blog was taking way too long. First I thought it should be resolved by implementing caching. Then I noticed that it couldn't be the caching, as I kept getting a TTFB that was way off. After some research I found the reason: IPv6!

Short answer

Say what!? Yep... I was surprised too. The short answer: open up your wp-config.php file and change the DB_HOST definition:

/** MySQL hostname */
/** define('DB_HOST', 'localhost'); */
define('DB_HOST', '127.0.0.1');

It's the driver!

The long answer: the driver that does the MySQL connection is not compatible with IPv6. When the driver is initialized, it needs to resolve the localhost and gets an IPv6 address. It connects, times out and decides to use the IPv4 address (127.0.0.1). That's why specifying the IPv4 address seriously speeds up your WordPress installation.

If your database runs on a different server, you can use gethostbyname to resolve the IPv4 address.

More info in this StackOverflow thread.

  1. girthdiggler says:

    awesome, great tip! Helped me a lot!

expand_less