Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

7 Ways to Boost Performance and Decrease Latency of Your WordPress Website

DZone's Guide to

7 Ways to Boost Performance and Decrease Latency of Your WordPress Website

WordPress is the top open-source CMS for creating websites. Learn some tips for boosting your page's speed and performance.

· Performance Zone ·
Free Resource

xMatters delivers integration-driven collaboration that relays data between systems, while engaging the right people to proactively resolve issues. Read the Monitoring in a Connected Enterprise whitepaper and learn about 3 tools for resolving incidents quickly.

WordPress is the number one open-source CMS to create blogs and websites. However, it has some performance issues in the default configuration that can’t be easily mitigated.

Also fast load speed is vital for all websites because this guarantees that users will be able to access your website more efficiently, your advertising in Google Ads will get a higher quality score and people will not leave your website because of a slow page loading.

At Hidora, we helped many customers to optimize their WordPress websites in the cloud and collected several important tips that can boost WordPress performance. These approaches can optimize your WordPress page load time to less than 1.5 seconds.

1. Use Nginx Instead of Apache Web Server

Although Apache is a well-known and proven web server, there are some alternatives on the market that can beat it. Among them is Nginx which is an open source web server that is used by 49.7% of the top 100,000 websites according to W3Tech.

Out of the box, serving static files, Nginx uses significantly less memory than Apache and can handle roughly four times more requests per second. This can be a vital argument for high-traffic websites that need to serve thousands of users per second.

2. Generate Static HTML Files

In most cases, your WordPress website is not being modified frequently.

You can use this fact to implement an advanced caching technique that will generate static HTML files from your dynamic WordPress site and, as a result, offload your WordPress site markedly.

How it works: Instead of building a new copy of the page for each customer request, you can generate a static version of the page. After an HTML file is generated your web server (either Apache or Nginx) will serve that file instead of processing the heavier and more expensive WordPress PHP scripts.

To generate static HTML pages, you can use free WP Super Cache plugin that will cache those pages immediately the first customer requests them. This cache can be automatically invalidated and rebuilt if necessary, either manually or automatically, if you submit a new page or a set period of time has elapsed.

3. Implement Faster Rendering by Using Async JavaScript and CSS Files

Most of the websites use tracking tools such as Google Analytics, Google Ads, Facebook Ads, etc. to track website visitors. However, these tools may dramatically slow down your pages due to the time taken to synchronously load their JavaScript files from the internet.

Asynchronous loading of JavaScript files can solve this issue. To do that, you need to specify the async attribute on your script tag. In addition, there are some WordPress plugins that can do this automatically for you.

Note: you shouldn’t mark all your JavaScript files as asynchronous because some of them are needed to render your page. We recommend making async only for unimportant scripts such as analytics and ads tracking codes.

4. Integrate CDN to Deliver Static Content to Your Customers Across the Globe

In addition to caching of static files on the web server or load balancer layer, you can achieve even better performance by using CDN. This makes total sense if your customers are distributed across the globe or located far away from your primary hosting location.

How it works: as soon as one of your website visitors requests an image, a video, a javascript or CSS file, it is cached on the CDN layer and distributed across multiple data centres that are located all over the world. All following requests of this static file are served from the CDN, which significantly offloads your server. The good news is that CDN delivers files from the closest locations to your customers: US-based customers will receive files from US-based data centres and Swiss customers from data centres located in Switzerland.

The downside of using CDN is that you need to tune the lifetime of each object correctly, otherwise your customers will see outdated versions of them. In addition, DELETE FROM CACHE operation is expensive at some CDN providers, so you need to use it carefully. In general, use of CDN can significantly increase the speed of your website and decrease latency.

5. Combine Multiple JavaScript and CSS Files to Minimize HTTP requests

If during page load a large number of files are synchronously downloaded this can increase page load time. In order to reduce the number of downloaded files, you can combine them into one JavaScript and one CSS file. As a result, many files can be replaced by 1 or 2 files. There are several free WordPress plugins that can do this for you. For example, Autoptimize can combine and minify both JavaScript, CSS files and fonts, and load them asynchronously to speed up the rendering of your web pages.

6. Use HTTP/2 Instead of HTTP/1.1

HTTP/2 enables HTTP connection multiplexing which can dramatically increase site load speed and decrease latency due to all your files being loaded within the same HTTP connection instead of opening multiple HTTP connections. If you have many static files this will definitely help you-you can check how many files are being loaded from your website using Pingdom test. Just see the difference in this demo that loads 379 small tiles using HTTP/1.1 and HTTP/2.

The good news is that HTTP/2 can be easily enabled on NGINX. You can follow this simple manual to integrate HTTP/2 on your website.

7. Make Your Website Available From Multiple Locations Using Anycast

If you have a large e-commerce site that serves customers all over the world, you can consider using Anycast IP and deploying WordPress instances in multiple locations. Each location entry point will be using the same public IP address. Customers will be routed automatically to the closest location based on their proximity to the target location. If any of those WordPress instances fails, the traffic will be automatically failed over to other locations.

The drawback of this approach is that not all cloud providers support the Anycast IP option and you have to own a block of at least 256 addresses. Another point is that you need to implement additional data synchronization features on the database and file system layers.

It is very important to optimize your page load speed. It will not take you long to implement all the tricks mentioned in this article, but the results will come quickly.

I hope you found my article useful. If you have any additional questions please don’t hesitate to contact me (or LinkedIn).

Discovering, responding to, and resolving incidents is a complex endeavor. Read this narrative to learn how you can do it quickly and effectively by connecting AppDynamics, Moogsoft and xMatters to create a monitoring toolchain.

Topics:
wordpress ,web performance ,performance ,latency ,performance optimization

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}