How to speed up a website on Wordpress

Optimizing WordPress sites to make them run faster is not new.

First and foremost here is to enable server side cache. It is also recommended to use a CDN for caching when delivering content. Let's take a closer look: what, where and how to cache.







For example, let's install pure Wordpress on the server of a domestic hoster. The time to generate one page from the start without any plugins reaches half a second. Full page load for a user from Europe takes about 1 second, in the US (west) - 2.2 seconds, in Australia - 2.8 seconds. The numbers were obtained following this instruction and based on site loading data from different parts of the world using the Webpagetest service .



As you can see, not too fast for an empty engine. So there is a reason for caching.



Server caching



The weak point of many sites is heavy queries to the MySQL database. In Wordpress, they are often generated by installed plugins.



The previous recommendations for speeding up the database using the query cache cannot be called a promising solution, because in the latest version of MySQL, caching was completely removed due to problems with scaling. Try installing the free Query Monitor and identify plugins that generate resource-intensive queries. If possible, turn them off or replace with adequate analogs.



If you still need to connect the MySQL response cache, you can use the open source ProxySQL query proxying tool for this .



Going further - PHP caching. In all recent versions since 5.5, the OPcache extension is enabled by default. Thus, the compiled code is automatically stored in memory for the fastest possible execution.



The result of the above MySQL queries and PHP scripts is the generated HTML code, which is presented to the user as a web page. If this HTML is temporarily (before making changes to the content) saved on the server and given to users without resorting to PHP and MySQL - the load time of such a page will be the shortest. This is how most Wordpress caching plugins work. They save the already generated HTML page as a file and render it in hundredths of a second.



Free WP Super Cache is the leader among cache plugins in terms of the number of installations . After installing it, enable caching and click "Refresh": The







working plugin adds information about the time of their creation at the end of the HTML code of the cached pages:



<!-- Cached page generated by WP-Super-Cache on 2021-02-24 17:51:50 -->
      
      





It is worth mentioning the possibility of using the Nginx cache instead of caching plugins . Its principle of operation is the same as that of plugins. Nginx generates temporary files in which it stores the results of previous requests.

To avoid getting confused with tiered caches, try to avoid using cache plugins and caching at the same time in Nginx.



CDN Connection for Wordpress



In addition to PHP scripts and MySQL queries executed on the server, the Wordpress engine also contains static files: pictures, styles, fonts, javascripts. The download speed of such files depends on their size and how far away the user is from them.



When it comes to file sizes, you should always watch out for this. Do not expect a few megabytes of fast loading from a picture on the mobile Internet.



In order for users from other countries and continents to load your files quickly, use a CDN . These are content delivery networks that store copies of your files on caching CDN servers in different geographic regions. By requesting a file via CDN, the user will receive it as quickly as possible from the nearest server.



Let's connect the CDN to your site. To do this, we will register on BunnyCDN and, having specified only an email, we will immediately receive 1TB of free world traffic for the test.



Then, in your personal account, you need to create a Pull zone, choosing a name for it and specifying the address of our site, from where files for caching around the world will be pulled:







Having created a zone, at the end, select "Wordpress" and follow the short instructions for enabling the caching plugin:







Result



After enabling the caching plugin and connecting the CDN, the website page load speed dropped to half a second for Europe and almost a second for the US and Australia. Visitors will definitely be satisfied, and views will increase.



Thus, in our example, pure Wordpress without images, users around the world began to load on average 2 times faster. For sites stuffed with pictures, styles and javascripts, the benefits will be even greater.



All Articles