Speed up any WordPress site in 5 easy steps
In this article we will explore some quick ways to optimize Wordpress websites and make them load faster.
WordPress is indeed an amazing tool that has been running a ton of websites all over the world for a long time. When it comes to using WordPress to build a website for yourself or for a client its very important to understand that WordPress was initially created for Blogging! ( ..and we are? ), everything else that brings extra features to WordPress core will be in the format of โPlug-insโ, plug-ins are basically a small set of PHP, CSS, and JavaScript files that will be integrating into your website. But I assume if you are a little geek you already know all of this sh**, so letโs move forward on how you can optimize your WordPress website by using 5 essential techniques.
ContentsSection titled Contents
- 1 โ Cloudflare ๐จโ๐
- 2 โ WP Rocket ๐โโ๏ธ
- 3 โ Redis, Redis & Redis! ๐ค
- 4 โ Picking the right theme ๐๏ธ
- 5 โ Find a good Hosting & Prefer a VPS
- 6 โ Battle with unknown & debug ๐ป
1 โ Cloudflare ๐จโ๐Section titled 1 โ Cloudflare ๐จโ๐
The first step that everyone should be using is Cloudflare! Cloudflare is a DNS manager and also CDN, it also brings a lot of nice features that a lot of people are not aware of. When creating websites for clients or even for myself I always make sure that Cloudflare is a requirement!
Here we will introduce some basic settings that you should enable & configure on the Cloudflare website to improve your WordPress website.
Cloudflare offers 3 different ways of SSL configuration. You should always make sure that your Hosting/VPS provider is giving you at least LetsEncrypt Free SSL certificates ( if not you should switch asap! Laravel Forge might be a good choice to provision your VPS).
We will provide here screenshots of our standard configuration for WordPress setups
1.1 โ HTTPS / SSLSection titled 1.1 โ HTTPS / SSL
In this step, please make sure that a certificate is already installed on your VPS/Hosting, if you are unable to generate a certificate temporary turn off Cloudflare SSL and try again.
You can now move forward to the next tab
1.2 โ Firewall RulesSection titled 1.2 โ Firewall Rules
The second step on Cloudflare, is to set up some basic firewall rules, this will make sure to keep most of the automated bots and brute-force attackers away from your website, and at the same time will make sure that these attacks donโt affect the performance of your server. The great thing here versus using plugins like iTheme security or Wordfence is : Cloudflare acts at DNS level, so these attacks will never bug you because they will be blocked at a higher level. Keep in mind that the rules we will show here are just basic, some website may require more or less tweaks based on your needs.
At this point you can also add more rules based on User Agent, URL and so on, some of the most common rules to keep attackers away :
- User Agent with : masscan/1.0, python-requests, WPScan
- URL contains: backups, .bak, backup, .env, setup.php, phpmyadmin
Hit Save and you are ready to go! This will make sure that anyone ( yeah even yourself ) will need to solve a captcha when accessing any page that contains wp-admin or wp-login at the URL. Why this is very effective? Because hackers often want to brute force those standard pages by default so you will save a lot of CPU and RAM by keeping them away! PROFIT!
2 โ WP Rocket ๐โโ๏ธSection titled 2 โ WP Rocket ๐โโ๏ธ
I have tried many different plugins for WordPress caching, minify and other performance/speed optimizations, W3 Total cache, WP Total cache and so on, but either i always found trouble at some point, some of them required extensive configuration, breaking styles, JavaScript and so on. Iโm a big fan of โkeep it simpleโ so here is were WP Rocket shines! With a few clicks and toggles you can get your website optimized without much technical knowledge, at the same point it will be compatible with most of the themes out there giving no issues at all. Some nice features we use on WP rocket:
- Cache / Separated mobile cache
- Heartbeat Control ( This is really have a huge impact in CPU )
- Lazy Load & Image Optimization
- Merge / Minify JavaScript
Keep in mind that if you are using Cloudflare to minify your CSS/HTML/JavaScript you donโt really need to toggle the minify options, otherwise, you will be doing the same optimization twice, at this point I would prefer to let Cloudflare handle it. You also need to be careful and add URLs that you want to exclude from caching, by default Woocomerce URLs are ignored, but some others such as Wish list and so on should be excluded manually.
3 โ Redis, Redis & Redis! ๐คSection titled 3 โ Redis, Redis & Redis! ๐ค
Yes! You might think its overkill, and yes it could be if your site does not have major traffic. But if your website runs Woocommerce and has a lot of products or heavy traffic a nice add-on to add is Redis Object Cache.
Redis Object Cache also has an enterprise version that claims to add even more performance ( i did not tried it myself ). If you donโt know what Redis is, you can read more on google, Iโm not going forward explaining here but basically Redis is a fast object cache that is available for many languages & plataforms, the port for PHP is called predis or phpredis that should be available as a PHP extension on your hosting provider or via composer.
When installed on WordPress threw WP Redis addon, it will make sure that repeated queries and objects will be blazing fast as they will be cached on memory, so you will save some badass queries to your MySQL database.
If all goes well, after some time you should see your metrics like the following screenshot:
4 โ Picking the right theme ๐๏ธSection titled 4 โ Picking the right theme ๐๏ธ
There is no doubt when it comes to themes on WordPress, there are available on the market. But this is a decision you should take very seriously and donโt rush on picking the first theme that looks good to you, a bad ( in terms of programming ) theme can ruin not only your server, but your user experience.
Often programmers take shortcuts and donโt really look at their code quality, most of the users donโt understand how to evaluate a good theme when purchasing, so here we will give you a few tips to find out if the theme is well done and fast!
-
Look how the HTML markup is organized, often bad markup, styling means the developer did not put a lot of time, this should also mean that under the hood the developer does not care.
-
Look how much CSS and JavaScript are being included by inspecting the code, the more JavaScript and CSS loaded the more bloat and more slow your site will be, keep it clean with fewer dependencies.
-
Try the theme in responsive mode or on your phone before you buy it. Often developers make the theme look good on desktop, but the mobile experience could be really bad, so its always good to have a look on how it looks on mobile, if you find little issues here and there may be the developer is not the best and did not put much effort on the mobile-first concept, this means maybe you should avoid it.
-
Check the reviews ( when possible ), this is really important, if you visit ThemeForest you can have a look on comments and reviews and check if there are other people who purchased the theme and are having issues, if there are any comments/questions/problems usually means the theme is buggy, otherwise people wouldnโt complain or call out the developer/agency a lot.
-
Give preference to Elementor Page Builder, why? Because its the 2021 page editor for WordPress, WP Bakery in my opinion is dead ( not official hehe ) but Elementor is a lightweight editor and also provides a lot of flexibility when it comes to customizing your pages in the future. Visual composer ( Formerly WP Bakery ) gave me some really bad memories, so i donโt really recommend it ( personally )
5 โ Find a good Hosting & Prefer a VPSSection titled 5 โ Find a good Hosting & Prefer a VPS
With more bloat everyday on Wordpress Core & Plug-ins around it, Wordpress websites tend to be a little bit CPU heavy, often costumers in Shared hosting will struggle with very slow response times, the reason for this is most of the shared hosting providers will cap your CPU usage because the actual CPU is being used by another 1000s of costumers. For this reason i would avoid as of 2021 to use Wordpress ( Specially if paired with Woocommerce ) on shared hosting if you want to keep your website blazing fast.
My recommendation here goes for a small/medium VPS, you donโt need to be a sysadmin to setup a VPS you can use services like Laravel Forge or Ploi.io to provision your VPS in a few minutes with very little effort. Please keep in mind that VPS will not bring any Cpanel ( unless you pay for it )
There also some nice solutions for managed hosting dedicated to Wordpress such as :
- https://wpengine.com
- https://kinsta.com
- https://www.siteground.com/
6 โ Battle with unknown & debug ๐ปSection titled 6 โ Battle with unknown & debug ๐ป
Sometimes you may have done everything but you still donโt know why your site is buggy or slow! This could be happening by a lot of reasons that we will describe bellow, but of course we cannot cover everything, but those tools will be really handy when it comes to debugging and tracking what could possibly making your WordPress Website slow!
-
Disable Plugins 1 by 1 ( Standard Engineer fix! ๐ ), keep testing if you notice any difference after disabling a certain plug-in.
-
Query Monitor: This is one of the best plug-ins when it comes to debugging. It will tell you about queries running, slow queries, requests going out and a lot of useful info, for instance, you can check what plug-ins are hitting your database really heavy, causing your website to be slow. The Swiss knife for WordPress Owners & Maintainers.
-
Snitch: What I love personally about this plug-in is you can keep track of whatโs going OUT from your WordPress website and block certain files/urls. This is pretty nice because you block constant plugins from slowing down your website by sending requests for updates every minute, blocking urls if they are taking too long to respond, block & track analytics being sent without your knowledge and so on.
-
Verify the integrity of your files with plug-ins like Wordfence, this is really handy if you believe some of your Wordpress core files were changed, sometimes hackers hide deep in Wordpress core files, itโs always good to run a quick check every few weeks.
-
Keep your plug-ins up-to-date, often plug-ins bring performance improvements, its always good to keep them updated just make sure it wont brake anything and always perform a backup first!
-
Disable WP_CRON, the Wordpress cron is triggered every time a user hits a page ( when necessary ) its good practice to whenever is possible to disable WP_CRON and instead use Crontab available in most all servers running Cpanel ยฎ or Linux, this will make sure no extra workload is being called without being necessary.
I hope you enjoyed this article leave your commend and clap on!