Optimising your website
Knowledgebase Article
}
Knowledgebase Article
As a website owner, offering a smooth browsing experience is paramount. An optimised site not only delights users but also positively impacts search engine rankings and environmental sustainability.
At Kualo, we're committed to speed. Our top-tier servers and cutting-edge technology are designed to host sites with optimal speed. However, every site is unique, and some personal tweaking may be required to reach peak performance.
In this guide, we outline nine actionable steps to help you do just that. If you're a WordPress user, these foundational steps should be your starting point, before proceeding to our in-depth WordPress optimisation guide.
Before we dive into debugging slow site speeds, let's understand what might be making your site slow and how you can verify it:
For illustration, we set up a test WordPress site with a stock theme and PageBuilder, and ran it through PageSpeed.
Here's what we found:
Mobile Before: 56
Desktop Before: 82
Not terrible, but definitely room for growth. Lower scores might indicate issues with the configuration of your site, such as excessive WordPress plugins or a less-than-optimal theme.
Google scores Mobile and Desktop differently due to varying connection speeds and computing power. Mobile devices usually have to contend with slower connections, making optimisation a more complex task.
Mobile After: 96
Desktop After: 99
Exceptional, right? But what does this mean for you?
PageSpeed's detailed insights pinpoint specific areas for improvement. These may differ between Mobile and Desktop, requiring individual attention. You can use these pointers to help improve your site speeds. This guide helps ensure optimal setup, including methods like caching, which can alleviate issues in more complex sites with multiple plugins or poorly optimised code.
For more specific improvements, follow these nine steps, and then consult our in-depth WordPress optimisation guide.
Every site is unique, and some may inherently run slower due to complexity. But with the methods in this guide even complex sites can perform impressively.
Before you dive in, we recommend that you read this guide in full. It's a roadmap to a site that's not just faster but smarter, more efficient, and more considerate of the world we share.
Most website owners are aware of the security benefits of keeping their website code, including any 3rd party applications, plugins, or extensions, up to date. What might not be as widely realised, however, is that these updates can also significantly improve site speed. Here's why:
By proactively maintaining an up-to-date website, you stand to gain not only in terms of security but also through increased performance. Regular updates are more than just a security measure; they're a foundational aspect of an efficient website.
At Kualo, we offer a variety of different PHP versions, and we give you the control to change the version of PHP you use via your control panel.
When your account is set up, it will utilise the latest stable version, but over time, newer versions of PHP are released. These more recent versions of PHP not only incorporate bug fixes and add new features but critically introduce speed improvements.
These can be significant; for instance, PHP 8 is now around 3x faster than PHP 5.6.
We don't automatically switch you to newer PHP versions because we can't be 100% certain that your website is compatible.
If your website code hasn't been updated in a while, it may depend on an older version of PHP; if we change it, your site might break. Before changing PHP, you may need to verify that all your plugins and themes are compatible with the latest version.
If everything is up to date, then it is likely that it will be compatible with a more recent version. If you spot issues after changing PHP versions, you can always revert to the previous PHP version.
You can follow this article to learn how to change the version of PHP used in cPanel.
OpCache was introduced from PHP 7 and helps make PHP sites faster.
To understand what OpCache is, think of PHP scripts like a letter written in English, but your computer, a robotic assistant, can only understand a mind-bogglingly long string of 0's and 1's. Every time you want the robot to read the letter (e.g., during every web page request), it has to translate it into this binary language.
Without OpCache, this translation into "opcode" (executable machine code) happens each time the code runs. It's like repeatedly translating the letter into robot-speak over and over again.
With OpCache enabled, a copy of that "opcode" version is stored on disk, so the next time the code runs, the robot doesn't have to translate it again. This makes the code run faster, as there is less work for the server to do.
The cached version will refresh any time a change is made to the PHP file; the entire OpCache can also be purged within cPanel.
If your site is performing slowly, take a look at your PHP Extensions in cPanel and make sure that OpCache is enabled for the version of PHP that your application is using.
Each of our hosting plans allocates specific amounts of the server's physical resources, such as CPU, Memory, Disk I/O, Entry Processes, and Number of Processes. Understanding and managing these resources is essential for maintaining optimal site performance. You can see the limits assigned to each of our hosting plans here.
Here's how different resource limits can impact your site:
You can monitor your resource usage through the "Resource Usage" feature in cPanel. This tool helps you identify if you've hit any limits in the last 24 hours or review historical periods.
If everything is well, you should see this screen:
However if your account has brushed up against any of your plans resource limits, you may see something like this:
The screen will show you what resource limit your site reached. You can click through to view more in-depth details, and you'll see a graph of your resource usage over the last 24 hours.
In the above graph, we can see that CPU usage has occasionally spiked and reached the available CPU resources of the plan, indicated by the red line.
Further down the page you will be able to view this data as a table, and you can order the table by any value. It can be an idea to order by Faults (which is the period which contains the most faults).
The ideal scenario would be that there are no faults for any category. If as in the table above you only have a handful of faults, in the double digits, this is usually not too much to worry about as this indicates only a handful of requests have faced issues.
If you're seeing much larger number of faults, then it's time for action.
You can also adjust the view to see your resource usage over a longer time period, by using the Timeframe drop down. This can be useful if you had a report of a slow website last week or if you want to see if things have improved following changes you've made.
Keep in mind that the longer the timeframe, the slower the results - so if you're looking at a big range it may be better to also adjust the time unit from hours to days.
Finally, the snapshot tab can tell you more about what was causing the resource spike, by showing you the running processes, MySQL queries or web requests that were running at the time you hit your resource limit.
This can sometimes give you an indication of the cause of the problem, particularly if you're running more than one application in your account as it can reveal which one is problematic.
However modern PHP applications often run via one central index.php file, and so in some cases it won't tell you the specific problem. It could be that a particular plugin in your WordPress is problematic, but as this is all loaded via index.php you might not get this insight. If this is the case, don't worry as the rest of this article will outline how you can make optimisations that could help eliminate this excessive usage in your application.
If you are hitting resource limits, the reasons could be:
Remedies:
In the following steps, we'll explore approaches to optimise the delivery of your website, shrinking that "packaging" to give your visitors the best experience.
Caching is the simplest way to speed up and minimise the impact of your website on the server. We already looked at OpCache above, and learned that PHP code is compiled on execution.
OpCache stores the compiled opcode in cache, but PHP is still required to execute to render every page request.
When a visitor accesses a page on your site, they make a request to the server which in turn executes your site code. It may make several queries to a MySQL database and run a bunch of functions that end up outputting HTML code that the browser can interpret as your web page.
All of this will take time to process, and without caching, every request from a visitor will result in the same thing happening.
Imagine if each time you wanted to read a book, you had to build a printing press first, learn how to operate it, print the book, learn the language, and only then could you enjoy reading. Exhausting, isn’t it? That's the server's life without caching! You're asking the server to do a complex, multistep task over and over again when it doesn’t have to.
When your application is configured with a cache, rather than do all of the processing to render that HTML page, it only does it when the page is first accessed. That resulting HTML is then stored, and the next time the page is accessed by any visitor, the cache simply serves up the page content.
If you make a change to that page, the cache will be automatically cleared, and when that page is next accessed it will re-generate the HTML code and store it back in the cache ready for the next visitor.
Using a cache can shave seconds from your page load time, and the result will be a faster site, and minimal resource usage.
Many applications have caching solutions either built in or available as a plugin, so there are a wide range of options to choose from.
If your website is built in WordPress, Drupal, Joomla, Magento, Prestashop, MediaWiki, or ZenForo, we’d strongly recommend that you use LiteSpeed Cache. This is because we run LiteSpeed Enterprise as our web server, one of the fastest web server technologies on the market. It features built-in server side page caching, with plugins available for all of the above applications.
Whilst there are alternative caches available, the benefit of using a server-side page cache is that the HTML code is cached on the web server layer itself, rather than as part of the application.
The plugins they provide don’t actually do the caching at all, they only manage purging that cache when you make changes.
Using LiteSpeed will not only make your site as fast as possible, but will also dramatically reduce your server resource consumption - allowing you to handle many times more visitors.
Redis and Memcached are like the cherry on top of the caching cake you've been building so far. They add one more level of speed-boosting to your website, and can often be used to target areas that are typically harder to optimise, such as those pesky admin areas. Popular open-source applications that can use Redis or Memcached include WordPress, Magento, Drupal, Joomla, MediaWiki, Laravel, and others.
Here's how they work:
In the context of WordPress:
Kualo is one of the few hosts providing these tools on shared hosting. If you're on a compatible plan (such as one of our Performance Plans) and your application supports this feature, don't miss out on this extra layer of speed and efficiency!
Note: If your application supports both Redis and Memcached, we typically see better results with Redis.
A Content Delivery network can help improve the delivery of your website internationally.
It does this by distributing your static content, such as images, javascript and CSS files throughout a super-fast global network. This brings those files closer to your visitors, wherever they are in the world. The shorter the distance files have to travel, the faster they’ll get there.
There are a number of excellent CDN solutions on the market, we’d usually suggest looking at CloudFlare (which is free with paid options) and BunnyCDN (which is exclusively paid but cost-effective).
If you use WordPress, another option is to use LiteSpeed’s QUIC.cloud CDN, which allows you to cache your HTML on their global network in addition to static content.
We cover this in detail in our LiteSpeed Cache Optimisation article.
MySQL database tables can either use MyISAM or InnoDB as the default engine. Think of them as two different types of filing systems for your data.
MyISAM used to be the default choice until MySQL 5.5.5, but then the preference shifted to InnoDB. Picture MyISAM like an older filing cabinet where the entire drawer gets locked when someone is using it. If someone else wants to access a file in that drawer, they must wait their turn.
InnoDB, on the other hand, is like a more modern filing cabinet where only the specific file or section being used is locked. If someone is using one part of the drawer, others can still access the rest without waiting. It's like multiple people having keys to different sections, ensuring a smoother, faster process.
Many applications will use MyISAM tables, and it may be the case that when WordPress or plugins are installed they default to this storage engine for maximum compatibility.
Although there are some advantages to using MyISAM, InnoDB is generally considered more reliable and performs better.
It's possible to convert MyISAM tables to InnoDB using PHPMyAdmin and our team can help with this. If you're a WordPress user planning to use LiteSpeed Cache, MyISAM tables can also be converted using their plugin in a few simple clicks.
We cover this in detail in our LiteSpeed Cache article.
Many of our customers use WordPress, so here's a tip that's exclusively for them.
In a WordPress installation, periodic tasks are often needed, such as updating check-ins, scheduling posts, or even backing up the entire site, especially when using certain plugins. These tasks are run by a behind-the-scenes tool called the wp-cron.php script.
Now, here's where it gets interesting: this script can execute when visitors access your page, not just when you're in the admin area. Imagine if every time someone walked into a shop, an employee had to stop and perform a random task like restocking shelves or tidying up. Sometimes, these tasks can be time-consuming, especially if it's something substantial like a full site backup.
This unpredictability can cause your site to slow down, especially if visitors happen to walk in when the 'employee' is busy with a complex task.
To ensure a smooth shopping experience, WordPress allows you to schedule these tasks at specific intervals, letting the wp-cron.php script handle its duties in the background without getting in the way of your visitors. This is akin to having a night-shift worker who performs the heavy lifting while the shop is closed, ensuring that everything runs smoothly during business hours.
Setting up this helpful feature is easy with Softaculous' WordPress Manager.
Just navigate to cPanel → WordPress Manager by Softaculous and find your WordPress installation. From the application's settings page, change WordPress Cron to 'Disabled'. This sets up a background task (a cron job) that takes care of wp-cron.php automatically, usually twice an hour. See this article for more details.
You can even customise how often this runs, but in most cases, twice an hour strikes the perfect balance.
In this comprehensive guide, we've explored a wide range of strategies to optimise the speed and performance of your website. We began with ensuring that your applications were up to date and that your PHP environment was well configured, including the appropriate version and use of opcode caching (opcache).
We then ventured into leveraging LiteSpeed Cache for popular applications like WordPress, Magento, Joomla, and others, and delved into more advanced methods such as employing tools like Redis, Memcached, and InnoDB. We touched on specific considerations for MySQL and also provided WordPress-specific tips to enhance both admin and visitor experience.
For our WordPress enthusiasts, don't forget to explore our in-depth LiteSpeed article for further insights and customised tips tailored for WordPress.
However, if any of this has your head in a spin or if you find that you're still running into speed issues, please remember that we're here for you. Reach out to us, and our dedicated team will be on hand to guide your website to the fast lane.
Happy optimising, and here's to a lightning-fast website!
Powered by WHMCompleteSolution