Results 1 to 2 of 2

Thread: Help! Time to first byte, output caching and PHP on IIS8!

  1. #1
    Join Date
    May 2014

    Question Help! Time to first byte, output caching and PHP on IIS8!

    Hi everyone,

    Usually I am pretty good at figuring things out on my own but I have been cracking my head on this one for days now. I have a website that runs Wordpress on IIS8 (PHP 5.4 and MySQL using InnoDB). By using WinCache my average time to first byte is now around 1400-1800 ms. Way too slow in my opinion as it takes this long for anything to display! I have tried enabling Output Caching in IIS8 to always cache .php files. This dramatically decreased my time to first byte to a mere 8 ms. Perfect! Or so I thought..

    The only problem I am facing then is that not a single part of my website gets updated once users interact with it. Considering my website loads every sub-page by query (Wordpress); it'll never transition to the new page! (I.e. I'll always see the home page and not the About Us or whatever page)

    This forces me to turn Output Caching in IIS8 for PHP files completely off and thus having my TTFB way too high. Do any of you know of any great caching options or tricks with either Wincache/FastCGI or Output Caching? I'd love to get my TTFB/Response Time down to the 8 ms I noticed was possible!

    I really appreciate the input!

    With kind regards,

    P.S. some background info: I am running a VPS with 4 cores and 5 GB of RAM on Windows Server 2012 with IIS 8.

  2. #2
    Join Date
    May 2014
    After many headaches I have finally figured out where a large chunk of this slow TTFB came from. PHP is at fault. Since the AAAA (IPv6) record takes prescedence over the A (IPv4) record, 'localhost' will return an IPv6 address. And as the MySQL driver (mysqlnd) in PHP cannot handle IPv6 addresses it first has to time out before it tries to connect over IPv4.

    I cut my TTFB from 1400-1800 ms to a mere 200-400 ms. Already tons better. The rest I can probably attribute to .css/.js calls and other things.

    To solve the above problem: instead of using 'localhost' use either or gethostbyname('localhost') as this function will always return an IPv4 address. The latter being the better solution as you might want to connect to an external MySQL DB one day by using a hostname.

    Hope this will help other people with TTFB issues!

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center