Speeding up Wordpress


    Wordpress in the standard installation is rather slow. By default, the engine does not use some features of the modern Web for its significant acceleration. There are a whole bunch of plugins for optimizing Wordpress. Let's put them in order and carry out capital optimization.

    Before getting started, let's see what the bare Wordpress installation of Pagespeed shows :


    The result of 76 out of 100 is pretty low. Let's see how much this indicator can be increased.

    Server side


    If you are not using Nginx yet, it's time to move to it. A simple and powerful solution. Configuration for working with permalinks support and static caching:

    server {
            server_name wp.com;
            root /var/www/wp; # путь к WP
            index index.php;
            location ~* ^.+\.(ogg|ogv|svg|svgz|eot|otf|woff|mp4|ttf|rss|atom|jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|bz2|doc|xls|exe|ppt|tar|mid|midi|wav|bmp|rtf)$ {
                    access_log off;
                    log_not_found off;
                    expires max; # кеширование статики
            location / {
                    try_files $uri $uri/ /index.php?$args; # permalinks
            location ~ \.php$ {
                    fastcgi_pass unix:/var/run/php5-fpm.sock;
                    fastcgi_index index.php;
                    include fastcgi_params;

    Php cache

    If you don’t have any special reasons why you cannot install APC, be sure to enable it. We check the availability of APC (in response we get a list of APC settings):

    php -i | grep apc

    In versions of PHP after 5.5, there is a built-in opCache module, so you won’t have to install APC.

    Tuning Mysql

    Wordpress uses InnoDB, which means we can significantly increase the performance of MySQL by adjusting a number of parameters (my.cnf file) for our hardware: It is

    better to put the size of the InnoDB buffer in half the available RAM:

    innodb_buffer_pool_size = 256M

    Do not forget to enable MySQL caching:

    query_cache_size = 32M
    query_cache_limit = 1M

    More advanced MySQL setup for Wordpress.


    This is the most important point. Caching can significantly speed up the site and save server resources. For clarity, we will use ab from Apache . Check out a standard installation of Wordpress without caching. We send requests through the local network, so there is nothing to delay except Wordpress itself:

    ab -c 10 -n 500 http://wordpress/

    We get the average request time of about 50ms:

    Total transferred:      4183000 bytes
    HTML transferred:       4074500 bytes
    Requests per second:    17.62 [#/sec] (mean)
    Time per request:       567.421 [ms] (mean)
    Time per request:       56.742 [ms] (mean, across all concurrent requests)
    Transfer rate:          143.98 [Kbytes/sec] received

    Chrome shows an average response expectation of 150ms (the server is located in the Netherlands):


    WP Super Cache

    This plugin allows you to enable caching in just one action. In addition to the standard settings, it contains a large number of parameters for tuning the cache. We download the plugin, activate it in the control panel and turn on the cache:


    With WP Super Cache turned on, we get a decrease in the average time per request by 25 times (!):

    Total transferred:      4293500 bytes
    HTML transferred:       4146500 bytes
    Requests per second:    499.01 [#/sec] (mean)
    Time per request:       20.040 [ms] (mean)
    Time per request:       2.004 [ms] (mean, across all concurrent requests)
    Transfer rate:          4184.61 [Kbytes/sec] received

    The average response expectation in Chrome has decreased by 3 times: Varnish


    can be used as a server alternative to WP Super Cache . It allows you to reduce the time it takes to process the request by almost an order of magnitude, but the solution itself is less flexible (well suited for blogs without dynamic elements).

    Styles, scripts and pictures

    Minification and compression

    CSS / JS minification can save 10 ... 15% of their size. To enable statics minification, there is a WP Minify module . Download, activate and the module will start working. Gzip will reduce the size of text files by several times. In Nginx, it turns on like this:

    server {
    gzip on;
    gzip_disable "msie6";
    gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript application/javascript;

    Image Optimization

    Pictures can make up a very large part of the overall page size. Lossless image compression can save 30 ... 40% of their size. The EWWW Image Optimizer module can do this . To use it, you will need to install imagemagick and the gd library:

    apt-get install imagemagick php5-gd

    Good practices and experience.

    • It is best to choose a VPS for Wordpress hosting. On Shared hosting, much of the above cannot be done. In addition, VPS is now quite cheap.
    • Check themes with Pagespeed before using
    • Empty the basket
    • Delete old post revisions
    • Delete spam comments
    • Turn off trackbacks when everything is getting really slow
    • Share RSS via feedburner

    As a result

    We were able to overclock the bare Wordpress installation by almost 100 times the page generation time (we turned on Varnish) and increase the Pagespeed indicator from 76 to 93:


    Useful tools and resources

    The P3 profiler will show the many bottlenecks of your current Wordpress installation. A convenient interactive checklist for optimizing Wordpress will allow you not to keep everything in mind, but not to miss anything.

    By the way, the analysis of sevenpercentcatherine.wordpress.com (hosted on wordpress.com) is gaining 83 out of 100 on Pagespeed. Of the problems - there is no minification and the response from the server is too large (350ms).

    Share your experience and Wordpress acceleration tools in the comments.

    Also popular now: