A website with short loading times is not only satisfactory for your visitors, but also has a positive effect on your search engine ranking. In this article, we will show you what you can do if your website loads slowly or is quickly overloaded when there is a high volume of visitors.
Measuring the loading time
If your website loads too slowly even with little traffic, we recommend that you first measure the effective loading time of your website. You can then use this later on to see whether any of the changes you make help.
To measure the loading time, you can use the Pingdom tool, for example.
Follow these steps:
- Go to the Pingdom website.
- Enter your domain in the URL field.
- Select your region.
- Start the test.
→ Any slow elements will be listed under “File requests”. - Look there for long loading times of elements like plugins, images and scripts and make a note of them.
Optimizations
Thanks to the analysis, you now have an overview of the elements that have long loading times and slow down your website. Based on the results, you can select the appropriate optimizations from the following list.
But even if you have not measured the loading time according to the instructions in the first section, the following optimizations can help to improve the performance of your website.
Deactivate plugins
Plugins can considerably impact the performance of your website. We therefore recommend only using the plugins that you really need. Unnecessary plugins include, for example, those that allow you to add the Google Analytics code to your website.
This can be done quickly, without much effort and without a plugin by using these Google Analytics instructions.
To see the impact of each plugin on your website, deactivate all plugins and reactivate each one individually. After reactivating each plugin, measure your page speed to find out which plugin is slowing down your website. Alternatively, you could also use the Query Monitor plugin.
GZIP compression and mod_deflate
GZIP is a compression program that compresses the files from your web server (e.g. text, CSS, images) before sending them to the browser, allowing the files to be transferred faster. You can test whether your website is already being compressed here.
Use the mod_deflate module to enable GZIP compression and save between 40% and 70% of the transfer volume. You can decide for yourself which compression rules to apply.
To enable the module, you need to add code to the website’s .htaccess file. Here’s an example in which text files (TXT, HTML, CSS, etc.) are compressed:
<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript
</IfModule>
Clean up database
The database that WordPress uses is filled with some unnecessary data during operation, such as:
- Deleted pages
- Spam comments
- Edits
- Deleted plugins
To optimize the database, you’re best off cleaning it up with a plugin such as Autoptimize or wp optimize. After installing the plugin, you may want to optimize CSS, JavaScript and HTML code.
Lazy Loading
It is possible to load images on a website with “lazy loading”. This means that data objects are only loaded when they are actually needed. This setting also has a positive effect on the speed of your website.
Caching
Caching is a key way of significantly increasing the performance of a website. Caching ensures that WordPress does not have to rebuild every page in the browser, but can instead access a finished version from the created cache. That’s why it’s important to use the server and browser cache.
The easiest way to configure your WordPress website’s cache is with plugins such as W3 Total Cache.
The functions of these plugins include:
- JavaScript lazy loading
- Minimize/minify CSS and JavaScript
- Database optimization
- Lazy loading
- Browser caching
- Page caching
WordPress with Nginx
Hostpoint allows you to use Nginx with reverse proxy and Apache.
A benefit of using Nginx with reverse proxy is that you can use the speed of Nginx in combination with Apache. The Nginx web server handles all static requests to the website while Apache handles the dynamic requests. This means that the Apache web server is less overloaded, resulting in a significant boost in performance.
The results of our tests using Nginx with reverse proxy and Apache were impressive. Compared to the same installation on shared web hosting, website performance increased by 50%. The two systems complement each other perfectly. With WordPress, we therefore recommend always working with a separate cache plugin.
What’s key here is that Nginx only actively caches if the HTTP headers have been set correctly. This article discusses the topic in more detail.
Cronjobs
Another way to improve performance is to replace WP-Cron with real cronjobs. WP-Cron is a WordPress cronjob that performs specific recurring work (e.g. checking for updates). A disadvantage of WP-Cron is that the cronjobs are always executed when the website is accessed. The server then has to process the website request and the cronjobs at the same time, which can overload the web host.
To deactivate WP-Cron and replace it with a real cronjob, do the following:
- Log into the Hostpoint Control Panel.
- Select your web hosting service.
- Click on “Explorer” in the menu and search for the wp-config.php configuration file in the directory of your WordPress website.
- Click on “Edit” and, before the line /* That’s all, stop editing! Happy publishing. */, add the following instruction to the file:
define ('DISABLE_WP_CRON', true); - Click “Save”.
→ WP-Cron has been deactivated. Now you can set up your own cronjob. - In the menu, go to “Advanced” > “Cronjobs Manager”.
- Click “Create a cronjob”.
- Paste the following code as a command, replacing the your-own-domain.ch folder in the path with the folder of your WordPress installation.
cd ~/www/your-own-domain.ch/; /usr/local/bin/php -q wp-cron.php > /dev/null 2>&1
- Set a time interval for execution (e.g. every 5 minutes). This article discusses the topic in more detail.
- Click “Save”.
→ The cronjob executes the wp-config.php file at the specified time interval.
Managed Flex Server
If you want to optimize the performance of your website even more, you can switch from shared web hosting to a Managed Flex Server. With a Managed Flex Server, you benefit from more resources (CPU/RAM) and additional cache options such as Redis in combination with cache plugins. All information about Managed Flex Servers can be found on the product page on our website.
For support requests please use this form instead.