High TTFB on wordpress site

I got a problem with a wordpress website, i got a TTFB of about 8s.

My server is a debian 7 with apache, 3go RAM, hosting at gandi cloud IAAS

Read More
  • If i install a cache module (like SuperCache), when a page is in the cache everything is OK, pages are loading very fast

  • But for a new page, or with the cache module disabled, it’s 8..9 seconds of loading.

My apache2.conf is configured like that :

 <IfModule mpm_prefork_module>
     StartServers          1
     MinSpareServers       1
     MaxSpareServers       3
     MaxClients            10
     MaxRequestsPerChild   3000
 </IfModule>

<IfModule mpm_worker_module>
    StartServers          1
    MinSpareThreads       5
    MaxSpareThreads      15
    ThreadLimit          25
    ThreadsPerChild       5
    MaxClients           25
    MaxRequestsPerChild 200
</IfModule>

A free-m request says :

               total       used       free     shared    buffers     cached
 Mem:          2858       1772       1085          0        166       1152
 -/+ buffers/cache:        453       2404

The url of the site is https://www.super-taux.com

If someone got an idea… Thank you very much.

Related posts

Leave a Reply

2 comments

  1. That is the nature of WordPress. The code and page Generation is generally horrific

    Your TTFB is not the problem. For WordPress it is pretty good.

    • Your Server does not caching any of the static content
    • Character set is not specified
    • Keep Alive is not enabled

    Your Server is Very Fast, 18,766,667 Bytes/Sec. and with the gzip compression the effective speed is 104,249,275 Bytes/Sec.

    • Base Page Size: 71,932 Bytes
    • Transmission Speed: 18,766,667 Bytes/Sec.
    • Compression: 5.6X
    • HTML Whitespace: 4.0%
    • Bytes Transmitted: 12,949 Bytes
    • HTML Transfer Rate: 104,249,275 Bytes/Sec.

    The total page load time is the issue.

    Typically with WP the order in which the CSS and JS files are loaded delays Start Render. If you test your page load at webpagetest.org, and look at the Waterfall you will see a large amount of time from the page loaded and Start Render.

    WebPagetest Waterfall Details

    The base page (Line 1) is loaded in 562 milliseconds, Start Render is at 2.789 sec.

    Notice line 22 is a .woff2 font file and its Start Offset is 2.511 sec.

    Then following that the Start Render begins. This one thing is costing you over 2 seconds.

    Each time the Browser runs into a resource (e.g. CSS and Fonts) that can alter page layout, the Browser restarts Rendering. Meanwhile each JS file that has been loaded prior to the last CSS stops Rendering as the Browser parses the JS.

    If SuperCache is working for you then you must have static web pages. With static pages you do not have to have WP Generate the pages dynamically.

    If you need WP to design your pages then copy the pages rendered by WP and use them as static pages.

    This may require you change the links from one page to another.

    Then you will also have the ability to correct the order of the resources in the <head> and move all the CSS and Fonts above any JS and move the appropriate JS down to the bottom of the page.

    Run the Google PageSpeed Insights

    PageSpeed Insights

    And follow the link to Eliminate render-blocking JavaScript and CSS in above-the-fold content

    You need to fix your Server configuration. it is best to add this to the httpd.conf but a quick fix is to create an .htaccess file that would include the following:

    AddCharset utf-8 .html .css .php .txt .js .svg
    Header unset ETag
    FileETag None
    ExpiresActive On
    ExpiresByType image/* A31536000
    ExpiresByType text/* A2592030
    ExpiresByType application/* A2592030
    <FilesMatch ".(js|xml|gz)$">
    Header set Cache-Control "max-age=2592030, public"
    Header append Vary: Accept-Encoding
    </FilesMatch>
    <ifModule mod_headers.c>
    Header set Connection keep-Alive
    </ifModule>
    <FilesMatch ".(ico|pdf|flv|jpg|jpeg|png|gif|svg|swf)(.gz)?$">
    Header set Cache-Control "max-age=31536000, public"
    </FilesMatch>
    <FilesMatch ".(html|js|css|xml|gz)$">
    Header set Cache-Control "max-age=86401, public"
    Header append Vary: Accept-Encoding
    </FilesMatch>
    
  2. Your site has very long time to Start Render (when the user sees something) and to a complete page.

    1) You are loading a lot of CSS, which delays rendering. Most of it (193 KB GZipped!) looks like Bootstrap and libraries to support swipebox. Do you really need all of that? For example:

    • Can you reduce Bootstrap down to the subset you really need (perhaps using Less or Sass)?
    • Where do you use swipebox? I don’t see it on the front page. If you are using a WordPress plugin that’s adding it in, many plugins simply add their CSS and JS to every page, whether they are being used on that page or not. This means that everyone has a performance penalty, even if most people will never see the lightbox. There are ways to disable plugins that do this on pages where they are not being used.

    2) You are loading a lot of Javascript files (perhaps from plugins). These also delay rendering. If you can limit them to the page(s) they are needed or make them asynchronous, then they will not delay rendering (but they will still slow down the page).

    3) You are getting a lot of delay from using SSL/TLS. Do you really need that for every page? Two suggestions:

    • Use SSL/TLS only on pages that really need it (where the user is going to enter sensitive information).
    • If you really need to use SSL/TLS, move all of your static content (CSS, JS, images) to a CDN. That way, you will not be getting the SSL/TLS penalty for static files.

    4) You use a lot of small images. Consider using a sprite instead. That way, there will only be a few images downloaded, saving a lot of HTTP connections (and extra penalty when using SSL/TLS).