Speeding up WordPress. How to speed up WordPress


  • Translation

Speed ​​and fault tolerance are one of the factors that invariably influence the popularity of your resource, because even with the best content in the world, a slow site will irritate readers and sooner or later you will lose them. In this article we will optimize the most popular blogging engine - Wordpress, running on PHP. At the same time, let’s look at a few general points in website optimization.

1 Testing the current speed

To find out if anything has changed after our optimization, it doesn’t hurt to first measure the current loading speed of your blog pages, so that you have something to compare with. There are several tools that will help you do this:

Don't forget to update to the latest version of PHP and Apache.

3.1 Disable unused services
You can get more available RAM by disabling unused services and optimizing MySQL and Apache.
  • Remove ClamD;
  • Configure SpamD to use only 1 child process;
  • Uninstall Mailman, unless, of course, you intend to run an email service.
3.2 MYSQL Query Cache
Since the stability and speed of Wordpress depends quite heavily on the operation of the database, it is worth making sure that the settings are in my.cnf correspond to the server's capabilities. First of all, you should set the request caching settings by adding my.cnf the following lines:
query_cache_type = 1
query_cache_limit = 2M
query_cache_size = 20M

For the settings to take effect, you will have to restart the MySQL service.
3.3 Compiler cache: XCache or Eaccelerator?
The compiler cache increases the performance of compiled scripts on the server by caching them - this will help reduce the execution time of PHP scripts. It's worth trying both solutions, but according to experimental results, the performance increase when using Xcache is 5% higher than with Eaccelerator.
3.4 Increase the maximum number of connections on Apache
Increasing the maximum number of connections in httpd.conf will increase productivity, because the server will be able to handle more connections at a time. However, you should change this setting carefully so as not to exhaust the entire amount of RAM and slow down the server, so always test new settings before putting them into operation. Let’s establish, for example, 150 connections:
max_connections = 150

Don't forget to restart the Apache service to apply the settings.

4 Code and graphics optimization

So, the server is up and running and now it’s time to play with the Wordpress code.
4.1 Disable hotlinks
Every time you use your server to store images, you are using significantly more of its resources. Quite often, people borrow your images by hotlinking them on their servers. This not only takes up the channel, but also creates a certain load on the server.
Add the following code to .htaccess file, replacing example.com to your domain name to disable the use of hotlinks:
< IfModule mod_rewrite .c >
RewriteEngine on
RewriteCond %(HTTP_REFERER) !^$
RewriteCond %(HTTP_REFERER) !^http://(www\.)?example\.com/.*$
RewriteRule .*\.(gif|jpg|png|ico)$ -
4.2 Use external hosting to store images
Hosting images on external servers will help significantly reduce the load on the server. In the example below, you can see a decrease in the amount of RAM used on one of the blogs after moving images to Amazon S3.

4.3 Compress java script code
Compressing javascript is a fairly simple task. Since it runs on every page view, you can reduce the size of the Javascript by removing all white space. Here's a simple tool that can do this for you - JavaScript Compressor.
4.4 Javascript at the top of the page
It often happens that the site starts to load slowly or stops altogether, because... another resource from which javascript is called (for example, Digg badges, Tweetmeme, etc.) is not available or is offline. To avoid this, place all the javascript code at the end of the page, and what could not be included for some reason, try enclosing it in an iFrame.
4.5 Use your browser cache
The browser cache itself, of course, will not make your blog faster, but it will help reduce the load on the server by caching frequently loaded objects (styles, interface elements, etc.).
Try pasting the following code into .htaccess file:
FileETag MTime Size
< ifmodule mod_expires .c >
< filesmatch "\.(jpg|gif|png|css|js)$" >
ExpiresActive on
ExpiresDefault "access plus 1 year"

4.6 Compress static data
You can reduce the page load size by allowing the browser to receive and transmit data in compressed form. This will also reduce channel load and the amount of data downloaded.
The following code in .htaccess can help you with this:
AddOutputFilterByType DEFLATE text/html text/plain text/xml application/xml application/xhtml+xml text/javascript text/css application/x-javascript
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4.0 no-gzip
BrowserMatch bMSIE !no-gzip !gzip-only-text/html
4.7 Use CDN for static files
If you store all the images on the same domain, the browser will wait for them to load one after the other. Let’s say you have 12 of them on the page, if you divide them between three subdomains, they will be loaded simultaneously from three “different” sources instead of being loaded by the browser one by one.
You can try moving all css & javascript files to files.yoursite.com, and images and temporary files on static.yoursite.com. Or simply use CDN (Content Delivery Network) - a large network of servers located around the world, which will allow you not only to store your files on different subdomains, which means download them in parallel, but also to deliver data to the user from the server closest to him. All this will allow you to load data much faster.

5 Wordpress

In this part of the article, we will look at performance improvement techniques that can be applied directly to Wordpress.
5.1 Update to the latest version
Updating to newer versions not only fixes detected vulnerabilities, but also improves performance. For example, in WordPress 2.8 the work with the database has been significantly optimized.
5.2 Disable Post Revisions
In all versions of WordPress, starting from 2.6, revisions of your articles were automatically saved every time you edited them. This slows down the database and increases its size unnecessarily.
To disable post revisions, add the following line to wp-config.php :
define("WP_POST_REVISIONS", false);

To delete previously saved text revisions, run the following query in PHPmyadmin:
DELETE a,b,c
FROM wp_posts a
LEFT JOIN wp_term_relationships b ON (a.ID = b.object_id)
LEFT JOIN wp_postmeta c ON (a.ID = c.post_id)
WHERE a.post_type = "revision"
5.3 Reduce the number of requests
Remove unnecessary queries to speed up page generation. For example, the following is a typical code found in all WordPress themes:
< meta http-equiv ="Content-Type" content ="< ?php bloginfo ("html_type" ); ?>; charset= " />

We can easily rewrite it in:
< meta http-equiv ="Content-Type" content ="text/html; charset=UTF-8" />

Already two fewer requests. Pretty simple, isn't it?
6 Wordpress Plugins
And finally, I bring to your attention several plugins that can improve WordPress performance. Once everything described above is completed, these plugins will help you achieve even better performance.

Wordpress in the standard installation is quite slow. By default, the engine does not use some of the features of the modern Web to significantly speed up its performance. There are a whole bunch of plugins for optimizing Wordpress. Let's put them in order and carry out a major optimization.

Before we get started, let's see what a bare WordPress installation shows by Pagespeed:

A score of 76 out of 100 is quite low. Let's see how much we can increase this figure.

Server part

Nginx
If you're not using Nginx yet, it's time to switch 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; # path 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; # static 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 cache
Unless you have some special reason why you cannot install APC, be sure to enable it. We check for the presence of APC (in response we will receive a list of APC settings):

Php -i | grep apc

PHP versions after 5.5 have a built-in opCache module, so you don't have to install APC.

Mysql tuning
Wordpress uses InnoDB, which means we can significantly increase MySQL performance by adjusting a number of parameters (my.cnf file) to our hardware:

It is better to set the InnoDB buffer size to half the available RAM:

Innodb_buffer_pool_size = 256M

Don't forget to enable MySQL caching:

Query_cache_size = 32M query_cache_limit = 1M

More advanced MySQL setup for Wordpress.

Caching

This is the most important point. Caching can significantly speed up your site and save server resources. For clarity, we will use ab from Apache. Let's check the standard installation of Wordpress without caching. We send requests through the local network, so nothing but Wordpress itself creates a delay:

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

We get an average time per request of about 50ms:

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

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

WP Super Cache
This plugin allows you to enable caching literally in one action. In addition to standard settings, it contains a large number of parameters for tuning the cache. Download the plugin, activate it in the control panel and enable the cache:

With WP Super Cache enabled, we reduce 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 (mean) Time per request: 2.004 (mean, across all concurrent requests) Transfer rate: 4184.61 received

The average wait for a response in Chrome has decreased by 3 times:

As a server-side alternative to WP Super Cache, you can use Varnish. It allows you to reduce the time for processing a 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
Minifying CSS/JS can save 10...15% of their size. To enable static minification there is a WP Minify module. Download, activate and the module will start working. Gzip will reduce the size of text files several times. In Nginx"e it is enabled 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 portion of the overall page size. Lossless image compression can save 30...40% of their size. The EWWW Image Optimizer module can do this. For it to work 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 VPS for Wordpress hosting. On Shared hosting, much of what is described above cannot be done. In addition, VPS is now quite cheap.
  • Test themes with Pagespeed before use
  • Empty the trash
  • Delete old post revisions
  • Delete spam comments
  • Turn off trackbacks when things get really slow
  • Share RSS via feedburner

As a result

We were able to speed up a bare Wordpress installation by almost 100 times in page generation time (we enabled Varnish) and increase the Pagespeed score from 76 to 93:

I present the most complete instructions with ways to speed up a website on WordPress. Using the methods described below, I speeded up the loading time of my site from 24.40 seconds to 1.41 seconds. Increased download speed by 17.3 times! Good result. To find out how, read the full article.

I measured the speed of the site using the Pingdom Speed ​​Test service. Tested the main page of the site. See below the site indicators “before” and “after” improvements, and short and complete instructions for speeding up the site.

Website loading speed indicators

Screenshot of speed measurement BEFORE optimization blog:

Screenshot of speed measurement after optimization and the recommendations below.
.

A short summary on speeding up a WordPress site

The main influence on the speed was made by such factors as changing hosting using SSD drives, optimizing images, enabling the W3 Total Cache caching plugin, optimizing the site database, deleting old revisions, enabling file compression on the server side, enabling a cache for static files on the browser side. What follows is a complete, detailed guide to speeding up a WordPress site.

Complete instructions on how to speed up a WordPress site

1. High-quality SSD hosting, fast ping

Hosting must be on SSD drives. It is advisable that the hosting servers be located in your geographic area to which the site is targeted. If the hosting is on an SSD, but in the USA, and your blog is focused on Russia and the CIS countries, then such an SSD will be of little use. Since there will be a long ping to communicate with the server. Therefore, the location of the hosting data center is also important. This is an important hosting parameter - fast ping, server response. And so that the hoster does not oversell services. About the type of hosting - of course it’s better to take a VDS (virtual dedicated server) with the parameters necessary for your site, instead of regular shared hosting. Which VDS configuration to choose depends on the load that your website creates not on the server and on the size of its daily audience. I would advise taking at least 1Gb Ram, 1 processor core and 10 GB SSD. At the beginning I had VDS on regular HDD drives, then I changed it to SSD VDS hosting.

Hosting "Before":

By prohibiting site indexing in this way, you can reduce the load on the hosting, and therefore speed up the loading of the site, freeing up server resources.

5. Setting up the .htaccess file to reduce the load on the server.

In the .htaccess file, additional commands for hosting are specified. Using special settings, you can remove unnecessary load on the server and speed up the site.

Setting No. 1. Often information is copied from websites along with pictures without changing the addresses of the pictures. And when this happens, images located on our hosting are loaded on other sites, and this creates an unnecessary load on the hosting.

The following code can prevent images from loading on our site on third-party sites:

RewriteEngine On RewriteCond %(HTTP_REFERER) !^http://(.+.)?yandex.ru/.*$ RewriteCond %(HTTP_REFERER) !^http://(.+.)?undsoft.com/.*$ RewriteCond %(HTTP_REFERER) !^http://(.+.)?yandex.net/.*$ RewriteCond %(HTTP_REFERER) !^http://(.+.)?feedburner.com/.*$ RewriteCond % (HTTP_REFERER) !^http://(.+.)?mail.ru/.*$ RewriteCond %(HTTP_REFERER) !^http://(.+.)?poisk.ru/.*$ RewriteCond %(HTTP_REFERER ) !^http://(.+.)?yourdomain.ru/.*$ RewriteCond %(HTTP_REFERER) !^$ RewriteRule .*.(jpe?g|gif|bmp|png)$ - [F]

After adding this code, an error will appear on someone else's site instead of your image.

Setting No. 2. In the .htaccess file, you can and should specify caching for some site objects (images, css and js files) so that the browser caches them on its side and does not download them every time. To do this, add the following code to .htaccess below the first code:

FileETag MTime Size ExpiresActive on ExpiresDefault "access plus 1 year"

Setting No. 3. Let's enable gzip compression of pages before sending them to the user. Let's insert the following code into .htaccess:

mod_gzip_on Yes mod_gzip_dechunk Yes mod_gzip_item_include file .(html?|txt|css|js|php)$ mod_gzip_item_include handler ^cgi-script$ mod_gzip_item_include mime ^text/.* mod_gzip_item_include mime ^application/x-javascript.* mod_gzip_item _exclude mime ^image/. * mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.*

Setting No. 4. Limit spam in comments. Most spam comments are sent automatically. With this code we will prohibit directly sending comments bypassing the comment form. Now spam bots will not be able to send comments.

RewriteEngine On RewriteCond %(REQUEST_METHOD) POST RewriteCond %(REQUEST_URI) .wp-comments-post.php* RewriteCond %(HTTP_REFERER) !.*yourdomain.ru.* RewriteCond %(HTTP_USER_AGENT) ^$ RewriteRule (.*) ^http: //%(REMOTE_ADDR)/$

Setting No. 5. If you use the FeedBurner system, then you obviously have plugins installed that send RSS content to the FeedBurner site. Today you can remove them, because you can redirect content without plugins, reducing the load on your hosting.

RewriteEngine on RewriteCond %(HTTP_USER_AGENT) !FeedBurner RewriteCond %(HTTP_USER_AGENT) !FeedValidator RewriteRule ^feed/?([_0-9a-z-]+)?/?$ http://yourdomain.ru

ATTENTION!!! In the examples above, do not forget to replace the address yourdomain.ru with the address of your website.

6. Database optimization

The Database is important in the speed of the site. When saving posts several times, WordPress creates post revisions - the states of posts at different points in their editing. As a result, over time, the database contains a large number of unnecessary post revisions, and these need to be cleaned and optimized. This can be done using Optimize DB plugin. You can install it from the WordPress admin area. For example, when I launched it on my website, I deleted more than 1,200 post revisions. This significantly improved the speed of the database.

7. Template (theme) code optimization

Optimizing the theme code involves removing unnecessary queries and/or replacing them with specific values, such as the blog title.

Setting No. 1. Find the code that is responsible for styles in the header.php file:

" type="text/css" media="screen" />

Replaced by:

Attention!!! Don't forget to change yoursite.ru to the link of your site.

Setting No. 2. Change pinback code:

" />

Setting No. 3. Changing the RSS feed code:

RSS Feed" href="" />

Correctly replace yoursite.ru with your link:

Setting No. 4. Quite often, in the footer of the site (footer.php), theme developers leave completely unnecessary queries to the Database. For example:

This code simply displays the name of the site, so as not to have to access the database again, it’s wiser to write the name yourself once and not load the site. You can search for the same code in other sections of the site, but think before deleting it.

1) If your site does not use comments, you should not hide them using plugins, this creates a completely unnecessary burden. Since you don't need comments at all, just remove the following code from your theme file (single.php):

2) Try not to use external scripts, such as comments from VKontakte, various social network widgets. Yes, it looks beautiful and impressive, but it creates a decent load on the site. From the examples, I can say that my site significantly loaded the web viewer code from YandexMetrica, the Add.This widget. I changed the social media buttons to a hotel JS plugin.

3) Clean all the code of your site from comments, these comments are inserted using tagsand /*code/. Leave only what you need, since the site has to spend extra effort loading them...

4) Try to place all scripts at the end of the page before the closing tag

so that the main site is loaded first, and only then the scripts are loaded.

5) All additional codes like the site counter from Live Internet, or Google Analytics should be placed in the footer of the site, so that they, like other scripts, are loaded only at the very end.

8. WordPress plugins - to speed up site loading speed

Some tips for working with plugins to optimize their load on the site.

1) Remove unnecessary plugins. Unnecessary plugin Over time, working plugins accumulate, and you can accumulate a lot of unnecessary plugins that, in addition to taking up space, will create unnecessary load on the site.

2) Deactivate unnecessary plugins. Try to use as few Activated Plugins as possible. Some plugins do not need to be allowed to work constantly. For example, a database optimization plugin can be enabled only for the period of work with it.

10. Speed ​​up your site using caching

Caching comes from the word cache, that is, storing certain data that should be constantly loaded. That is, the site saves certain data, and when you go to the page, the user’s browser simply downloads the saved data in the form of a page. The site does not have to contact the server and database, then wait for a response, collect the necessary information and give it to your reader’s monitor.

1) WP Super Cache is the best and free caching plugin for WordPress. I recommend installing and using it. Also good plugins are WP Total Cache and WP Rocket.

2) Autoptimize plugin– recommended to use together with Wp Super Cache. You don’t need to make any additional settings, just activate the plugin, in the “Settings” → “Autoptimize” section, check the boxes, and the plugin will work. Be careful, check the functionality of the site after changing the settings to prevent yourself from trouble.

3) WP Widget Cache plugin– allows you to cache widgets, which the Wp Super Cache plugin cannot handle.

11. Use CDN networks to load content faster

Another way to speed up site loading is to use CDN networks, Content Delivery Networks. Every time a user opens your site, he downloads all the information from your server on which the site is located. If the user’s region and the region where the server with your site is located are the same, say Moscow, Russia, then everything is fine. But if a user visits your site, say, from Asia or the USA, then the content will be delivered to him at a lower speed, because Distance plays a role here. Using CDN networks makes it possible to download your website files (images, scripts, styles) not only from your hosting, but from data centers around the world. Thus, when visiting the site, the user will automatically download the site files from the point closest to him with the CDN network servers, which will significantly speed up the loading of the site.

You can use the Jetpack Photon plugin, which allows you to use the WordPress CDN network to upload images of your site.

You can use other CDN networks, such as MaxCDN, NGENIX or Amazon CloudFront. I have not used CDN networks, so at this point I will limit myself to only a brief introductory description of this technology.

By connecting your site to the CDN network, all site files will be downloaded from the most powerful data centers around the planet. Typically, such services are paid, the cost starts from $9, and they are used by very popular sites with huge traffic.

A few little things that will also help you speed up the loading of the site:

  1. On the main page of the site, display only article announcements; there is no need to display full articles.
  2. Separate very large articles into pages using a tag.
  3. You should not display more than 5-6 articles on the main page.
  4. You should not display more than 50 comments under an article; also use switching pages between comments.
  5. Install a site search from Google or Yandex. The site will search for information faster.

That's all for me dear friends, thank you for your great patience, I hope you liked it, see you soon.

Article outline

For Google, Yandex and other search engines, site loading speed is an important ranking factor. Let's look at speeding up the loading and operation of a website using the WordPress CMS. The results of the work can be seen at the end of the post.

Goal: Speed ​​up the loading and operation of the site on the CMS WordPress with plugins (without editing the code).

Step 1. Analysis of the current situation with download speed.

I accelerated this blog back in February 2015, so the screenshot of the previous state was not saved. From memory I remember that the PageSpeed ​​Insights service showed loading speeds of 50/55 for mobile/desktop. The condition was deplorable and I started thinking about acceleration.

Analyze your WordPress site using the Google PageSpeed ​​Insights service and if the site load result is less than 85, read on.

Step 2. Install plugins for acceleration.

WP Fastest Cache

Plugin for website caching, file compression, minimizing and combining css, js, very wide functionality. The plugin is free in the required configuration.

Go to the admin panel of the WP site in “Plugins” -> “Add new”. Enter the name of the plugin, click “Search”. The first plugin with an image of a cat-type animal is our plugin. We install.

EWWW Image Optimizer

Plugin for image optimization. Compresses existing and downloaded images without losing quality.

Go to the admin panel of the WP site in “Plugins” -> “Add new”. Enter the name of the plugin, click “Search”. The first plugin with a hammer image that hits pictures is our plugin. We install.

Step 3. Setting up site acceleration on WordPress

Let's set up caching and minimization of css, js files. In the admin panel, you now have WP Fastest Cache as a new menu item. Follow the link, below you will see the language field, set the Russian language. Check all the boxes, as in the screenshot below. You don’t have to go to other tabs of the plugin - there are paid functions for which you are unlikely to want to pay money.

After that, we will compress the images on the site. In the WP admin panel, hover over the media files, select “Optimize”. In the selected window, use two functions - optimizing images from the library and optimizing other images (template, engine, etc.). By these actions you compress existing images on the site; images downloaded after installing the plugin will be compressed automatically when uploaded to the server.

Just these 2 steps will significantly speed up page loading, which will increase search engine loyalty and improve people’s attitude towards your WordPress site.

Step 4. Site acceleration results.

The results are amazing. From 50 it immediately became 81 (again, from memory). After reading Google's recommendations, I found many loading problems associated with the plugin, which is designed to beautifully display program code on a blog. After I demolished it, this value rose to 91! Here's what Yandex Metrica showed - the page loading report:

From the screenshot you can clearly see that Page loading speed decreased from 1 second from 0.1. I note that positions in Google and even Yandex have improved, the number of failures has decreased (some people, especially with mobile Internet, do not want to wait long and leave the site if, after going to the site, it does not immediately begin to load).

Additionally

Do not use original images if you need to display the image in a small size.

This significantly reduces loading speed and Google's attitude towards the site. A simple example - on my blog on the main page you will see text and a small photo above the feed of the latest posts. If I put a link to the original image with a resolution of ~1000×2000 in the src attribute of the img tag and displayed a 100×100 image, the server would have to load the 1000×2000 image, the browser would compress it to the required dimensions, which I specified in the display styles, but the original was actually loaded. Therefore, I was not too lazy to resize it in Photoshop and only then use it in the template. Upload images exactly in the resolution you want to display it in.

Less graphics means faster site.

Graphics take up hundreds and thousands of times more space than a few lines of CSS and HTML. Try to create website elements using these markup languages ​​whenever possible.

Fewer plugins means fewer database queries.

Do not install dummy plugins that are needed for some dubious purposes that you can do without. By installing just a dozen extra plugins, you will significantly increase the load on the database and, accordingly, reduce the speed of the site.

If you have problems speeding up your site on WordPress or have any questions on the topic, write in the comments or email using the form on the left - I will try to help.

Is it possible WordPress optimization and acceleration using simple methods? Certainly! Even though WordPress is lightweight and fast by default, setting it up incorrectly can make many processes slow and extremely confusing. We suggest you pay attention to ways that will help speed up your website.

According to recent research from Microsoft, the time users wait for page loads has decreased from 12 seconds to 8 seconds, and people have become more impatient. Moreover, studies have shown that 40% of users will leave your resource if it takes longer than 3 seconds to load. Therefore, optimization and acceleration of WordPress is simply necessary.

1. Optimizing WordPress and regularly updating your own database.

WordPress is a content management system based on relational databases. If the database is large, this may lead to slow performance Internet resource .

The following parameters need to be considered when using a large database, which can cause WordPress to run slowly:

  • Post revision: Function " Post revision» quickly fills the database, after which the Internet project begins to work slowly. Each updated post is saved in the database. This is how the database is filled. This function can either be disabled completely or limited. To limit revisions, you need to go to the settings file wp-config.php add the following lines:
define("AUTOSAVE_INTERVAL", 300); //seconds define("WP_POST_REVISIONS", 5);

After code changes, WordPress stores a maximum of 5 post changes and only 5 minutes. If necessary, you can turn on the “Revision of posts” function again.

  • If you don’t want to change the code for the wp-config .php file, you can install the plugin - Revision Control or the plugin for removing post revisions - WP Clean Up. Then an optimized WordPress will automatically start managing post revisions. You can find out more about how to install and manage.
  • Blog links and trackbacks: Blog links and trackbacks can also populate the database. They can also be disabled. This can be done like this: Settings/Discussion/Allow notifications from other blogs (notifications and trackbacks) to new articles
  • Blog comments: Comments on a blog are not bad at all, but only if they are not thousands spam comments, which take up space in the database. It is imperative to regularly delete such comments so as not to “clog” the database.
  • Plugins.
  • Some plugins collect data and load it into a database. They seem useful at first, but in reality they just take up a lot of space. For example, one plugin can use up to 160 MB. database space. This is just one plugin! What if there are several of them? Analytics and registrations.
  • You need to be careful with plugins that analyze the history and registration of data on a web project. Basically, they use a large amount of database, which can lead to slow page performance and worsen WordPress optimization.
You can install the WP-Cleanup plugin and use it to clean and optimize your database.

The time it takes to load on the page depends on the size of the images. This happens when you need to upload a high-resolution image, or when a photo is published in articles and then displayed on the home page.

Exists 2 ways to optimize own pictures:

Regularly optimize and reduce the size of photos; this can be done without degrading the quality of the photo;

In this case it is perfect free service OptiPic, it will automatically compress all the images on the site for you without your participation.

By the way, if you have a large number of images, you can use the code discount coupon for paid mode and 5% discount, copy the code dSAdDeN2xj7_Nr9B1LH68MoyeuJxMeUY

· Delay loading of images; This method is used when a photo does not load while the reader is scrolling the window where the photo is. This method will help you avoid problems loading the website. To do this, you can use various plugins, for example Lazy Load and similar ones with a similar name.

Optimizing the image allows you to reduce it from a size of 2 MB. up to 600 kb. without compromising quality. This is done to remove unnecessary parts of the image. Photos can be optimized in a WordPress blog using special plugins installed.

Without a doubt, like this WordPress optimization will have a great impact on the loading speed of your portal, since it is usually unoptimized images that take the longest to load, this is especially true for mobile devices and the mobile Internet.

3. Using the cache and removing headers.

Most WordPress web resources could be twice as fast if they used caching.

WordPress optimization through caching is based on storing web resource files in the visitor’s browser cache or ready-made pages on the server, that is, it automatically saves the page to the cache file periodically when a visitor visits the site. Typically, if the cache settings are not changed, then the visitor's browser cache will be updated when the web project is updated, thereby ensuring that nothing is lost.

To use caching effectively, you can use a plugin that I myself use WP Super Cache. This plugin speeds up the loading of WordPress and optimization is achieved by saving ready-made pages to the server disk. Thanks to this, when a browser requests a page, the blog does not have to create the page from scratch each time. In the case of a standard download, he needs to make many queries to the database, process the PHP program, and so on. With a cache, a ready-made result is produced immediately.

Caching can significantly increase the speed of your blog. It has been found that full caching capability can speed up a WordPress blog by anywhere from 2.4 seconds to 900 milliseconds.

After enabling caching, you can also enable the header expiration module, this is the Apache http server module mod_expires. This optimization will increase the speed of WordPress by notifying visitors' browsers when to request certain files from the server. And forcing it to store files in the user’s browser for the required time. The mod_expires module can save server resources and significantly increase page opening speed. For details on what entries to write in .htaccess to activate the module and configure it correctly, read the article " ". On our hosting, this module is enabled by default for all websites. Thereby already improving their optimization from the very beginning.

4. Enabling GZIP Compression via mod_deflate.

What is the most popular tool for compressing files to Zip format on a computer? 7-Zip? WinRar? How many have compressed files and seen the amazing efficiency when a 200 MB file is reduced to 40 MB in size? How does this happen? Is technological compression impossible in this way? Everything is possible, you can do the same for a blog, and thereby ensure its fast operation and excellent optimization.

GZIP Compression helps compress page files into Zip format and transmit the entire page to visitors, thereby optimizing loading speed. For this, the Apache mod_deflate http server module is used. In other words, attendance Internet pages the same, but the blog itself is fast, since visitors are served by a compressed version.

We tested a web resource that was compressed using GZIP Compression from 68 kb to 13 kb, Worpress accelerated its loading by 5 times.

How to launch and configure this module on a good hosting such as ours is described in the article "".

5. Using a CDN.

There are studies showing that a CDN can increase blog performance by 60%.

The loading speed of page content depends on where the hosting is located on which the web project is located. For example, if the hosting is located in India, and the login comes from, for example, the USA, then the site will load slower than if it happened in India. How to get out of this situation? People with limited Internet access speed can use the CDN service to speed up website loading.

For a WordPress web portal to use a CDN service, it needs to distribute the content globally so that users can use the version closest to them.

6. Optimize and change the WordPress theme.

WordPress themes can also take a long time to load your blog. If you use a WordPress theme that is bloated and based primarily on external requests, your blog will run slower compared to those using standards-based themes. It is clear that optimization here will be quite difficult.

7. Combining the background of the image with the moving sprite.

The WordPress theme is based on a background image, combined with CSS commands, predominantly the display is a clear background. So one beautiful background can consist of 12 different backgrounds. On the surface it looks normal and simple, as long as these 12 backgrounds are used as 12 different requests to the server from the visitor's browser. What if these 12 drawings were combined into one? Then the speed will increase sharply.

When combining a background with a sprite, you can combine different background themes of an image into one and then use CSS to get a regular page display. This will reduce the overall number of bytes required to be downloaded by users' browsers, which was causing latency. The result is a faster blog and better optimization.

8. Use only non-synchronous calls for JavaScript codes.

Have you noticed that when Facebook freezes, other web resources begin to work noticeably slower? Interestingly, this does not happen when Facebook codes are loaded. This happens when synchronous codes from other sites are used - especially analytics or tracking. If the code is installed synchronously on WordPress, it is loaded first - depending on the part of the code - before loading other elements of the site.

By using only JavaScpipt's non-synchronous code feed, it is guaranteed that the blog functions properly and quickly no matter what JavaScript code server is used on the web project.

You can find out more about what this is.

9. Enable HTTP Keep-Alive.

This setting is possible if you have access to the http server configuration. In other cases, I recommend using normal hosting.

We have Keep-Alive support enabled for all clients for free!

Typically, when a visitor requests a file from a server, each file is sent individually. The problem in this case is that a new link is opened for each file, which ultimately leads to a slow blog depending on how many people are visiting the web resource at the same time. By enabling HTTP Keep-Alive, all files are served to visitors' browsers through a single connection. The connection is open until all files are received. Thus, the number of open connections on the server is reduced, thereby increasing the speed of the site.

10. Use the best host.

If the host is bad, then the tips presented in this article won't make much difference. In such conditions, optimization is difficult. With regular analysis and research of web hosts, it is noticed that in 2 cases out of 10, if the server configuration is poor, then nothing can be done to increase the speed of the portal.

One magazine described cases showing how much the web host affects the loading time Internet pages. The programmer compared the speeds of the blogs of two clients, one of which used a dedicated server, the second - a shared one. The result was stunning: the response time of the web resource to requests on a dedicated server was 7 ms, while the response time of the site on a shared server was as much as 250 ms.

The web host definitely matters. Therefore, before you buy hosting somewhere, try ours. The first month you can use it completely free. Or you can even take a free plan.

Finally, I suggest you watch an excellent video where many points from this article on optimizing and speeding up WordPress are shown visually.