CleanTalk is a SaaS spam protection service for Web-sites. CleanTalk uses protection methods which are invisible for site visitors. Connecting to the service eliminates needs for CAPTCHA, questions and answers and other methods of protection, complicating the exchange of information on the site.
WordPress in the standard setting is quite slow. By default, the engine does not use some features of modern web for significant acceleration. There are a whole bunch of plugins to optimize WordPress. Let’s put things in order and undergo a major optimization to accelerate WordPress.
Before we begin, let’s see what shows raw installing WordPress on Pagespeed:
Result 76 out of 100 is pretty low. Let’s see how you can increase this figure.
Server part
Ngnix
If you’re not already using Nginx, it’s time to move on it. Simple and powerful solution. Configuration for supporting permalinks and static caching:
server { server_name wp.com; root /var/www/wp; # way to 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; # statistics caching } 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 cach
If you do not have any special reasons why you can not install APC, turn it necessarily. Checks for APC (in response to obtain a list of settings APC):
php -i | grep apc
In PHP versions after 5.5 has a built-in module opCache, so it will not have to put the APC.
Tuning Mysql
WordPress uses InnoDB, which means we can significantly increase productivity of MySQL, adjust the number of parameters (file my.cnf) under our hardware:
The size of the buffer InnoDB is better to put in half the available RAM:
innodb_buffer_pool_size = 256M
Do not forget to include the caching of MySQL:
query_cache_size = 32M query_cache_limit = 1M
Caching
This is the most important point. Caching can give a significant acceleration of the site and save server resources. For clarity, we will use ab from Apache. Verify the standard install WordPress without caching. The request is sent through a local network, so the delay is nothing but itself does not create a WordPress:
ab -c 10 -n 500 https://wordpress/
Obtain the average time of about 50ms on request:
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 the average wait for the response at 150 ms (the server is in the Netherlands):
WP Super Cache
This plugin allows you to enable caching literally in one action. Besides the default settings, it contains a large number of settings for tuning the cache. Download plugin, activate it in the control panel and turn on the cache
With the included WP Super Cache obtain a reduction of the average time per query 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
Average absorption waiting for reply in Chrome decreased by 3 times:
As an alternative to server-WP Super Cache can use Varnish. It reduces the time to process a request for nearly an order of magnitude, but the solution is less flexible (well suited for blogs without elements of dynamics).
Styles, scripts and images
Minification and Compression
Minification CSS / JS can save 10 … 15% of their size. To enable a module minification statics WP Minify. Download it, activate, and the module starts. Gzip will reduce the size of the text files into several times. In Nginx activated as follows:
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; ... }
Optimizing images
Pictures can be very large part of the overall page size. Lossless compression of images can save 30 … 40% of their size. This module is able to do EWWW Image Optimizer. For it to work you will need to install imagemagick and library gd:
apt-get install imagemagick php5-gd
Good practice and experience
- It is best to choose a VPS hosting for WordPress. Shared hosting on many of the above can be done. In addition, VPS now cheap enough
- Check the topics using Pagespeed before use
- Clean trash
- Delete old revisions of posts
- Remove spam comments
- Unplug trackbacks to moments when everything becomes very slow
- Share RSS via feedburner
As a result
We’ve got a raw install WordPress to disperse about 100 times on the page generation time (we included Varnish) and increase the rate at Pagespeed from 76 to 93:
This text is a translation of article “Ускоряем WordPress” by golotyuk published on habrahabr.ru
Forums and blogs without spam
CleanTalk is a SaaS spam protection service for Web-sites. CleanTalk uses protection methods which are invisible for site visitors. Connecting to the service eliminates needs for CAPTCHA, questions and answers and other methods of protection, complicating the exchange of information on the site.