WordPress caching settings
When you set the PHP and caching settings in your cPanel and WordPress website correctly, you will experience a better performance. Your website is not only much faster, but it also process much more traffic simultaneously. This functionality is included, free of charge, and you can set it up yourselfby following the steps below. Below, you will find a step by step explanation of what caching is and how to apply it for WordPress sites hosted on Hoasted in an optimal manner.
What is Caching?
A cache is a part of the server memory. Recently saved and / or frequently used information are stored here. When a web page is requested, all components are invoked from the website (database, PHP scripts, images, CSS files, etc.), and a result of all scripts will be shown. Through that process, which has a short duration (average between 200 ms and 3 seconds), all PHP scripts are invoked and calculations re-performed.
When a site is cached, this means that only the result (the cache) of the scripts is displayed (your site will be served from the cache). This is a very efficient way to make your website very fast. For example, if you receive 10 website visitors at any given time, the website is loaded normally to the first visitor and then immediately put into the cache. For the next 9 visitors the website will be loaded from cache, making the loading time much shorter.
The cache of your website or webshop is automatically recreated when a user makes a change in the web site.
Step 1: cPanel settings
- Login to the cPanel
- Go to 'Select PHP version' under Software > SELECT PHP VERSION
- Tick the OPCACHE + APCU boxes
- Click on save
Step 2: WordPress settings
- Login to the WordPress installation
- Instal the plugin 'W3 Total Cache' (W3 Total Cache) on your website and activate
- Go to the plugin settings (You can do this in your WordPress admin under menu item 'Performance' > 'General Settings') and set the following items:
- General: Toggle all, don't set this (leave deactivated)
- Page caching: activate this and set to 'disk enhanced'
- Minify: don't set this (leave deactivated)
- Database Cache: don't set this(leave deactivated)
- Object cache: don't set this (leave deactivated)
- Browser Cache: activate this (activate)
- CDN: don't set this (leave deactivated)
- Reverse proxy: don't set this (leave deactivated)
- Monitoring: don't set this (leave deactivated)
- SAVE ALL SETTINGS
If you also use an SSL certificate on your domain we suggest to activate the option 'Cache SSL (https) requests' 'Page Caching'.
Step 3: deactivate other caching plugins
In case you previously used other caching plugins, it is important that they be deactivated in your WordPress backend. Below is an overview of the most common WordPress caching plugins:
- WP Super Cache
- WP Fastest Cache
- Zen Cache
- Cache Enabler
Step 4: Exceptions (i.a. for Woocommerce users)
In case you're using Woocommerce or dynamically generated pages, it is imperative that you process the URL's of your website / shop in the caching plugin. You can do this with the following steps:
- Under 'Performance' > 'Minify', you can add 'mfunc' to the list ‘Ignored comment stems' like in this example.
Caching exceptions for shop and account pages (Woocommerce)
- Under 'Page caching' > 'Never cache the Following pages' you can add the following caching exceptions. You do not want to pages related to user accounts, shopping carts and checkout are cached, as these pages include dynamic content. By adding these exceptions to the W3 Total Cache plugin these pages will never be cached.
If your shop pages have other names, then you need to add then (ie above URLs + your own WooCommerce URLs). Such is the case if you installed WooCommerce in a languageother than English. If you're not sure what the exact links to your WooCommerce shop page are, you can find them in your system. View them in your system status using the following steps:
- Open your WordPress dashboard
- Go to Woocommerce > System Status
- A page with a list of all your WooCommerce settings opens. Under the heading 'WC Pages' you can see under what URL your dynamic WooCommerce shopping pages are. You can see this the examples below, the names (Winkelbasis) of the pages, the page ID (# 8) and the url slug (/ store /). What you need is the URL slug (in this case /winkel), which you can add to the aforementioned caching exceptions.
Below you can see what a Swedish Woocommerce webshop can look like.
Caching exceptions for other pages (for other dynamic pages)
- In case you have other pages that are dynamic and may not be cached, you also add them to the list.
If you have any questions or need assistance with your caching setting, feel free to send an email to email@example.com, and one of our colleagues will gladly help!