📜 ⬆️ ⬇️

Create faster and more optimized WordPress sites

Most consumers have already established views on web hosting services. If you look for reviews on any hosting provider, you will find dozens of results. And usually, there are more negative reviews than positive ones. I think I can fix it, so I’m sharing with you the tasks that I have to face as an operator of hosting support for WordPress , as well as their solutions.

I have compiled a list of bad web solutions, as well as recommendations on what to do on your site. The list is based on thousands of hours of communication with customers, as well as support and troubleshooting that I encounter daily. Some of the proposed will be quite primitive, and some questions will be more advanced level. Much of this can separate a successful WordPress site from a failure. Indeed, despite the fact that the choice of the right web hosting is very important, you should spend enough time optimizing your WordPress site so that it will be successful.

I often notice that experienced developers focus on the fact that they are good at creating certain web solutions, which makes them neglect or simply forget about learning and applying actual optimization methods. Regardless of whether you are new to WordPress, or an experienced developer, the following tips will help you create much faster and more optimized WordPress sites.
')
1. Changing hosting is not always the solution
2. Working sites are not intended to be developed.
3. Not a developer? - Do not go into the code
4. Do not save on themes and plugins.
5. Monitor AJAX requests
6. Be careful when working with advertising networks and external services.
7. Over-optimization can harm performance.
8. Popular performance problems are easy to diagnose.
9. Modifying WordPress core is bad
10. Ensure compatibility with PHP 7 and HHVM before transferring the site.
11. Large sites should be engaged in database optimization.
12. Do you really need a universal theme?
13. Error log is your friend
14. Google is here for a reason.
15. 123456 is no longer allowed.
16. Scripts should not always be loaded throughout the site.


1. Changing hosting is not always the solution


One of the most important things that people need to be aware of is that changing web hosting will not solve any problems by itself. If your WordPress site has problems with code or conflicting plug-ins, your site won't fix wherever you place it.

Administered hosting will provide you with as much support and assistance as you can, but will not debug code or plugins. Writing good PHP code, creating and editing plug-in functionality and themes, editing the integration, as well as filling the site with content is not the responsibility of the web host. This can be done by an experienced developer who will understand the work of the site, study the problem and solve it.


2. Working sites are not intended to be developed.


I can repeat it a thousand times. Never use working sites for development! Now almost all major WordPress hosted administrators have development and run-in environments, and, of course, not without reason. Using these solutions saves us from an emergency crash of the working site due to unsuccessful attempts to test something.

If you do not want to use such solutions, you can take advantage of local development and testing using what some call LAMP or LEMP stack. They are designed to work with Linux, Apache / Nginx, MySQL and PHP. And tools like WAMP and MAMP will simplify and speed up server building for local development.

All of these tools have improved and evolved over time, however, local development has its own problems, for example, an environment that doesn’t accurately simulate your published site. First of all, you will have to figure out how to redirect your work from the local machine to the working site so that you do not have to overwrite the existing data, and the site does not fall. Depending on your settings, this process can be a separate problem. Certain difficulties may arise with conflicting ports or errors due to differences in MySQL versions.

To avoid such problems, I recommend using tools such as DesktopServer and Local , which are designed exclusively to speed up your workflow when working locally with WordPress. They include simplified ways of transferring data to the working site, and also have additional features, such as working with WP-CLI and built-in support for multisite mode. Multisite support itself can be invaluable, since working with large local copies of WordPress can sometimes be quite complex.

Run-in and local testing environments can help you deal with problems before they break your site.


3. Not a developer? - Do not go into the code


People who are either not familiar with WordPress, or do not know the basics of programming, should not edit files. One of the most common reasons why sites on WordPress are falling is that someone is editing a PHP file directly from the appearance editor in the control panel. In addition, you should not edit a working site, as mentioned earlier.



Recommendation for administrators: put the following code in the wp-config.php file with the substitution edit_themes , edit_plugins , and edit_files privileges for all users. This will prevent users from dropping the site by editing the code.
define('DISALLOW_FILE_EDIT', true); 


Also, disable the ability to edit theme files or install plugins for users. To do this, place the following code in the wp-config.php file .
 define('DISALLOW_FILE_MODS', true); 


Note , the above commands will also disable the file editor for themes and plugins. More information in the WordPress Codex .


4. Do not save on themes and plugins.


It is clear that you would like to save a couple of dollars, but you should not do it at the expense of themes and plugins. WordPress should be the foundation of your site, and themes and plugins are the glue that keeps the project’s functionality together. Try to stick to reputable developers when choosing plugins. Learn in advance about the history of product support by the developer, review the ratings and read the reviews. Such a study can be a daunting task, with more than 50,000 plugins in the WordPress directory .

Very often outdated or poor-quality themes and plugins are susceptible to the introduction of malware or are engaged in installing malicious content and links to your site. According to the WP Loop research , almost half of all published plugins have not been updated for more than two years. This is both shocking and frightening.



Another source of plugins and topics worth exploring is third-party catalogs offering premium solutions at low prices. If you select this source, you will not support the developer. In addition, you rely on an unreliable source of updates, which is also not very good.

Waiting for updates to installed plugins is a huge problem for WordPress users who buy solutions from third-party directories like ThemeForest. Many themes developers build additional plugins into them, such as Revolution Slider or Visual Composer. The point here is that when vulnerabilities are detected in the embedded plug-in, the user has to wait for the update from the theme developer, although the plug-in itself could be fixed almost immediately. This makes many sites very vulnerable to hackers.


5. Monitor AJAX requests


Watch how AJAX requests are used on the site, as well as plugins using AJAX. For example, the WordPress Heartbeat API uses /wp-admin/admin-ajax.php to access AJAX through a browser. Many of these appeals are superfluous. Especially frequent use of this file occurs when traffic surges and CPU usage. This can significantly slow down your site. This is somewhat similar to launching a DDoS attack against yourself.



If there are third-party plugins that use admin-ajax.php, make sure that they interact with it correctly. You can easily track HTTP POST requests and, based on the name, determine which plugin they are called by. For example, the one I discovered, get_shares_count , turned out to be a popular plugin for interacting with social networks, which was overloaded by admin-ajax.php. On a high traffic site, the overload would increase many times over.

However, AJAX is loaded only after loading the page itself, so if you see the corresponding warnings in the speed test, it is not always an AJAX problem.


6. Be careful when working with advertising networks and external services.


Most sites with high traffic earn on advertising, and the rejection of third-party ad providers is not possible. Nevertheless, it is important that the number of third-party services was minimal - you need to understand how much they load your site.

Here is a brief comparison of how ad networks can impact your WordPress site.

Testing options: I added three ads from Google AdSense, 300 Ă— 250, to the test resource. The site has a default theme - Twenty Sixteen. I measured download speeds before installing AdSense, and after.

Before AdSense ( test results )




Breakdown of content by compound:


After AdSense ( test results )




Breakdown of content by compound:



By simply installing 3 Google AdSense ads, we added 6 additional connections. WordPress site with advertisements 2.7 times slower than without them. This is mainly due to the additional DNS lookup time and the use of javascript on the page. All this should create for you a picture of what is happening on large sites that insert 10 ads per page. No matter how fast hosting you use, it will not correct delays from third-party advertising connections.

Below is another example of a site with a large number of external advertising HTTP requests, which caused a heavy load on WordPress.



There were so many requests that the application server did not load at all. The site was simply unavailable, trying to fulfill all external requests.



Another good example is the Huffington Post site. If you test the download speed, you will see a huge number of HTTP requests to ad networks. A quick test showed a download speed of over 13 seconds!


But the simple removal of advertising is unlikely to be a good solution, because many sites receive most of their income from it. We'll have to do to optimize the loading of their scripts. You can use asynchronous loading of scripts or postpone their loading so that they do not interrupt the rendering of your pages. When it comes to performance, you always have to balance between perceived and actual performance.

Example asynchronous javascript:


 src="example.js" async 


Example of deferred javascript:


 src="example.js" defer 


Patrick Sexton has another JavaScript snooze method . WordPress version 4.1 and higher has a filter with which you can easily add the async or defer attributes to your scripts.

Typically, using external services, you want to cache responses. What for? Because, if you do not do this, a “white screen of death problem” may arise. Each external service you add must be from a trusted and trusted source. In the end, if they fall, it will affect your entire site or your business operations.


7. Over-optimization can harm performance.


There are thousands of articles on the Internet that give “tips” on how to speed up and optimize a WordPress site. But there is nothing worse than when users over-optimize their sites. Yes, it happens more often than you think. WordPress site owners often feel that adding something will double their download speed.

Below, I have listed a few problems that I meet regularly:

Attempt to cache cache


Unlike typical VPS or regular servers, many WordPress hosting companies have their own caching, which is done at the server level (for example, Redis or Memcache). Many providers prohibit the use of caching plugins, because using them can cause all types of problems, but more often, 502 Bad Gateway. Trying to cache cache, as I call it, is never a good idea.

Plugins, such as WP Rocket and Cache Enabler, are great, but they were designed for servers that need extra help to speed up your site. I recommend reading in more detail about object caching - a popular server form of caching that is often used today.

2 Ă— CDN = 2 Ă— download speed, right?


CDNs can actually significantly reduce content download time in different geographic regions, but only with proper configuration. One of the most popular services is Cloudflare, which is technically a proxy server, and is slightly different from a regular CDN provider, since you send all your DNS to it, and not just the content of the site.

I usually see users connecting Cloudflare, then adding KeyCDN or MaxCDN in addition. This often happens due to the fact that they read someone's blog posts, where they see recommendations to try new services. They install new services, forgetting about the already connected, and, although this combination can work under certain scenarios, more often than not, everything ends in confusion. In most cases, it is worth using either Cloudflare or a third-party CDN provider, each of which has its own advantages and disadvantages.

A huge number of SEO-plugins does not provide a higher position in the search results


You want to dominate the search results, this is understandable. But the addition of 3 SEO plugins will not help you achieve this goal. In fact, there are many compatibility issues that arise when using All In One SEO, Yoast and other SEO plugins at the same time, for example, the output of duplicate meta tags . Installing additional plugins does not guarantee improvement of your search engine optimization.


8. Popular performance problems are easy to diagnose.


Even if you are not an advanced WordPress user, common performance problems are fairly easy to detect. For advanced users, I recommend using WebPageTest , as it supports the latest HTTP / 2 protocols. For the rest, Pingdom will do. A simple cascade analysis will show you whether you have unnecessary redirects, missing files, an excess of DNS queries, or site overload through third-party scripts or ad networks.

Take a look at the performance scores and response codes, and you will learn how to start solving errors on your site.




9. Modifying WordPress core is bad


Make it a rule: making changes to the WordPress core to get your code working is a bad idea. Especially on a working site. Such manipulations can create vulnerabilities in your site. And if you didn’t consider updating the changes for new kernel versions, your edits will be lost with each new WordPress update. Best of all, if you use the built-in tools and functions of WordPress, plug-ins, child themes and hooks.


10. Ensure compatibility with PHP 7 and HHVM before transferring the site.


PHP 7 and HHVM are known to be very helpful in improving the performance of WordPress sites. And of course, it is always pleasant to use the latest and the best. But first you should make sure that your site is compatible with these technologies. For example, if you are upgrading from PHP 5.6 to PHP 7, you should test all the functions of your WordPress site in the running environment or locally to make sure that there are no compatibility issues. One outdated, but very important plugin for you may not work with PHP 7, which means that you will have to wait for its update before switching to more recent technological solutions.


11. Large sites should be engaged in database optimization.


One of the easiest ways to slow down a large WordPress site is not to optimize the database. Simple tasks, such as cleaning up traces of old versions of WordPress or removing unused tables, can protect your site from slowing down. Also, I noticed that many old sites still use MyISAM in their databases. InnoDB, at the moment, is much faster and more reliable solution.

You can convert your tables in just a few simple steps. First, make sure you are using MySQL 5.6.4 or newer, and also that you have made a backup, as a precaution. This example uses the wp_comments table. Just run the ALTER command to convert to work with InnoDB.

 ALTER TABLE wp_comments ENGINE=InnoDB; 

If you are working with the current version of phpMyAdmin, you can open the desired table, go to the “Operations” tab and change the storage mechanism there.



Another simple optimization method is to disable or limit the number of stored fixes in the database. You can add the following to your wp-config.php to completely disable them.
 define('WP_POST_REVISIONS', false ); 


Or simply change the number stored for each post or page:
 define('WP_POST_REVISIONS', 3); 


I came across many sites with more than 200 versions of posts. If your hosting does not have internal optimization, WordPress settings will have to be set manually, because by default, it will store an unlimited number of corrections.

If you have saved a lot of changes on your site, you can run this script in phpMyAdmin to remove them:
 DELETE FROM wp_posts WHERE post_type = "revision"; 


You can also use the WP-Optimize plugin for this purpose.


12. Do you really need a universal theme?


There is a huge problem that I observe in the WordPress community. People buy universal themes, and use only 1% of its functionality or even less. They look at the demo pages and see beautiful sliders and customized blocks that convince them of the need to purchase, however, in fact, these features may never be useful to them. You can buy a simpler and less functional topic, and thus save both money and time, which, as a result, will be spent on its optimization, because a simple topic will be faster right out of the box.

I do not want to say that all universal themes are bad. In fact, with proper configuration, they can work very quickly - this is an example with the Avada theme, which is loaded in 700 ms .



However, to optimize an existing topic will take a lot of knowledge and time. For most WordPress users, if they don’t use half the theme functionality, using simpler themes is the answer. Do not let beautiful banners and fancy sliders fool you. Most often, this whole set of options will only slow down your site.


13. Error log is your friend


If you know how to deal with WordPress files and the wp-config.php file, the error log can do you good service. By regularly testing it, you save yourself from all sorts of headaches, as well as learn more about the work of WordPress. Few users look into the log before asking for help from the hosting technical support. With a few simple settings in wp-config.php, you can enable error logging, which by default is stored in /wp-content/debug.log.

Enable logging:
 define( 'WP_DEBUG_LOG', true ); 


The output of logs on the page:
 define( 'WP_DEBUG_DISPLAY', true ); 

Read more in WP_DEBUG codex .


14. Google is here for a reason.


Do not be afraid to search for answers in Google. The internet is full of tips and solutions. Within a couple of minutes, you can fix most of your problems. Answers to common questions, such as “how to change DNS in GoDaddy” or “how to use sFTP”, can easily be found on Google.

There are major WordPress resources on the Internet, such as the StackExchange and WordPress Codex , not to mention the hundreds of blogs with tutorials.

In addition, a good hosting WordPress, most likely, has its own convenient knowledge base that will help users find answers to questions, and hosting - to reduce the time to support users in typical cases.


15. 123456 is no longer allowed.


SpashData collects a list of the most frequently used merged passwords (more than 2 million) each year. It is not surprising that in 2015 the most popular password was “123456” - the same as in 2014. This is rather unpleasant for hosting sites, since the use of such passwords keeps sites literally one step away from hacking. One of the best solutions is to use KeePass or its analogs. Encrypted password in the cloud is always much safer than “123456”.


16. Scripts should not always be loaded throughout the site.


Unfortunately, unlike a static manual website, a WordPress site is dominated by themes and plugin developers. And not all developers care about the performance of their decisions. There are a huge number of plugins that upload their scripts to all pages of the site, although the plugin itself is used only on one of them. If we consider that there may be several dozen plug-ins, the problem multiplies, and the site slows down.

One such example is the popular Contact Form 7 plugin. As shown below, it uploads CSS and JavaScript files to the home page of the site, although no contact form is used there.



There are several ways to fix this. The first is to use the wp_dequeue_script () function, introduced in WordPress 3.1. It allows you to remove scripts from the download queue on your site. Here is an example of using this feature with Contact Form 7. The developer of Contact Form 7 also has documentation on how to use JavaScript and CSS only where necessary.

The second way is to use special plugins for WordPress, for example, Gonzalez or Plugin Organizer . Below is an example of using Gonzalez on our website. A convenient settings window allows you to remove the Contact Form 7 plug-in JavaScript and CSS files from all pages except the contact page, thereby increasing the download speed of the rest of the site.



Conclusion


There are reasons why WordPress is used by more than 28% of all websites . This is a very reliable, convenient and versatile CMS. Everyone, from the authors of home blogs to several hundred companies, relies on it every day. But just like with most platforms, if WordPress is used incorrectly or not optimized, working with it can quickly turn into a headache.

Source: https://habr.com/ru/post/330918/


All Articles