Server Setup

Server Optimisation

Setting up your server for faster page speed.

The Server Is The Backbone Of Your Website

Don’t Overlook Your Server Setup

Ensure Your Server Is Fast

Getting the correct server setup for attaining faster pagespeed scores is a simple, but critical step in achieving the best scores you can. There are a few important steps to take into account when setting up / purchasing your server. As with the rest of this guide, I won’t tell you all the confusing technical reasons as to why this must be done, rather give you an overview of what to look out for and how to set it up correctly.

To set the scene, cheap (or shared hosting like offered by Godaddy or Rackspace) is not the way to go. With this type of hosting, you are sharing too many resources and the time to first byte (TTFB) is massively delayed. Sharing PHP workers can also cause serious ‘hangs’ if another website you are sharing resources with gets busy.

So you must go with hosting that has it’s own environment. Cloudfare is also a must if you have a global website. This simply replicates the media / larger files on your website on hundreds of servers around the world. The response time for a Cloudflare setup enables data to transfer from your website to any end global user more quickly than any other server set up / CDN.

However, if you are a local business do not a CDN at all. It will actually slow down your website for your local target market by introducing another server into the supply chain.

Server Optimisation

Setting up your server for faster page speed.

The Server Is The Backbone Of Your Website

Don’t Overlook Your Server Setup

Ensure Your Server Is Fast

Getting the correct server setup for attaining faster pagespeed scores is a simple, but critical step in achieving the best scores you can. There are a few important steps to take into account when setting up / purchasing your server. As with the rest of this guide, I won’t tell you all the confusing technical reasons as to why this must be done, rather give you an overview of what to look out for and how to set it up correctly.

To set the scene, cheap (or shared hosting like offered by Godaddy or Rackspace) is not the way to go. With this type of hosting, you are sharing too many resources and the time to first byte (TTFB) is massively delayed. Sharing PHP workers can also cause serious ‘hangs’ if another website you are sharing resources with gets busy.

So you must go with hosting that has it’s own environment. Cloudfare is also a must. This simply replicates the media / larger files on your website on hundreds of servers around the world. The response time for a Cloudflare setup enables data to transfer from your website to any end global user more quickly than any other server set up / CDN.

However, if you are a local business do not a CDN at all. It will actually slow down your website for your local target market by introducing another server into the supply chain.

Getting the correct server setup is a simple, but critical step in achieving great speed.

There are a few important steps to take into account when setting up your server.

Setting up your server for faster page speed.

As with the rest of this guide, I won’t tell you all the confusing technical reasons as to why this must be done, rather give you an overview of what to look out for and how to set it up correctly.

To set the scene, cheap (or shared hosting like offered by Godaddy or Rackspace) is not the way to go.

With this type of hosting, you are sharing too many resources and the time to first byte (TTFB) is massively delayed.

Sharing PHP workers can also cause serious ‘hangs’ if another website you are sharing resources with gets busy.

Server Recommendations & Setup Guide

Improving Server Performance

Host Close To Your Customers

Hosting your website close to your customers is important, and the reasoning behind it is very similar to how a CDN works. This is especially if you have a website servicing local customers.

Why Is This Important?

Imagine your business is in London. You service customers locally who visit your website. Now imagine your website is hosted in New York. Your customers are on their phone or computer, and click on a link. That click then has to travel all the way to New York, retrieve the data, then come all the way back to London again to appear on their screen. Why not just host it locally on a server in London?

This not only saves the data a long trip, but it also cuts down waiting time for the customer, and makes your site more responsive for your target audience. It massively improves TTFB and not only will customers see this, but your local Google algorithm will measure it too, boosting your local web rankings.

Any Recommended Web Hosts?

I won’t go into some huge hosting reviews, just give my recommendations. There are plenty of web hosting reviews out there but I will narrow it down to two hosts that I recommend for their performance and flexibility.

Firstly Kinsta. If budget does not matter (it’s $30 a month) then just go for it. It’s Nginx based. Everything on this page is already setup (plus a whole lot more) and it’s easily the fastest web host out there. Not only that but it’s based on the AWS / Google Cloud architecture and has Cloudflare built in. There is no messing about setting it up – it’s just ready to go out of the box.

Take a look at their servers on the Kinsta Website. You will attain the best pagespeed scores and website response times using Kinsta WordPress hosting and you can choose to host your website in any one of a multitude of countries to suit your needs.

The second option if you’d prefer a cheaper host with cPanel is A2 Hosting. Being US servers, they are best for USA based websites.

As long as you go for the turbo hosting, you will get good pagespeed scores. Hosting is super cheap but for once, I can recommend which is not normal for cheaper hosting. You have a little more to do here than at Kinsta, but Cloudflare is included which is amazing at this price.

You can see the A2 Turbo Packages on this page.

Enable Compression

You must enable GZIP compression on your web server. This compresses files by as much as 85% and can slash seconds off your website load time. This is one of the biggest instant pagespeed boosters there is.

How Do I Enable Compression?

Most hosts do have this enabled by default, but do a check here by typing in your domain name. If it’s not enabled, put the following code at the top of your .htaccess file:

<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE text/javascript
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE image/x-icon
AddOutputFilterByType DEFLATE image/svg+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/x-font
AddOutputFilterByType DEFLATE application/x-font-truetype
AddOutputFilterByType DEFLATE application/x-font-ttf
AddOutputFilterByType DEFLATE application/x-font-otf
AddOutputFilterByType DEFLATE application/x-font-opentype
AddOutputFilterByType DEFLATE application/vnd.ms-fontobject
AddOutputFilterByType DEFLATE font/ttf
AddOutputFilterByType DEFLATE font/otf
AddOutputFilterByType DEFLATE font/opentype
# For Olders Browsers Which Can’t Handle Compression
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
</IfModule>

Once it’s enabled, clear your server cache and WordPress cache, and retest your website using GTMetrix or Google Lighthouse.

Set An Efficient Cache Policy

When the browser caches your page’s static resources, it stores a local copy of these resources in its cache, making file retrieval much faster.

This is known as a caching policy and it simply tells the browser how long to store each file type for.

Longer cache policies instruct the browser to keep these files for longer (e.g., 1 year). This is important for resources that are unlikely to change frequently, like a logo image, or page fonts. Shorter cache policies are great for resources that change frequently, like CSS and JavaScript files.

How Do I Set My Cache Policy?

It’s similar to the step above. Depending on whether you have an Apache (cPanel) server, or NGINX one, just put the following code into your .htaccess file and all will be set.

No need for plugins to set cache policies!

Apache

<IfModule mod_expires.c>
ExpiresActive On
# Images
ExpiresByType image/jpeg “access plus 1 year”
ExpiresByType image/gif “access plus 1 year”
ExpiresByType image/png “access plus 1 year”
ExpiresByType image/webp “access plus 1 year”
ExpiresByType image/svg+xml “access plus 1 year”
ExpiresByType image/x-icon “access plus 1 year”
# Video
ExpiresByType video/webm “access plus 1 year”
ExpiresByType video/mp4 “access plus 1 year”
ExpiresByType video/mpeg “access plus 1 year”
# Fonts
ExpiresByType font/ttf “access plus 1 year”
ExpiresByType font/otf “access plus 1 year”
ExpiresByType font/woff “access plus 1 year”
ExpiresByType font/woff2 “access plus 1 year”
ExpiresByType application/font-woff “access plus 1 year”
# CSS, JavaScript
ExpiresByType text/css “access plus 1 year”
ExpiresByType text/javascript “access plus 1 year”
ExpiresByType application/javascript “access plus 1 year”
# Others
ExpiresByType application/pdf “access plus 1 year”
ExpiresByType image/vnd.microsoft.icon “access plus 1 year”
</ifmodule>

Nginx

Usually, Nginx servers are setup for this, but if not add the following snippet to your server block. You usually have to do do this at:

/etc/nginx/site-enabled/default

location ~* \.(jpg|jpeg|gif|png)$ {
expires 365d;
}
location ~* \.(pdf|css|html|js|swf)$ {
expires 30d;
}

Again, clear your server cache and WordPress cache, and retest your website using GTMetrix or Google Lighthouse. If everything goes to plan, your cacheing should be all setup.

Is That Everything?

That is all you need to worry about for now. There will be some additional writes to the .htaccess file, but this will be done by a few plugins as we go through the process.

What About Cloudflare?

Some hosts like A2 or Kinsta have it all setup for you – you just need to tick a box to get it going.

If your host does not have auto integration, then Cloudflare has a good integration guide you can read. For the everyday user, I like to recommend a host that does have auto integration.

Server Setup Complete!

Step 2: Install Plugins

Time To Get To The Nitty Gritty

Improving Server Performance

Host Close To Your Customers

Hosting your website close to your customers is important, and the reasoning behind it is very similar to how a CDN works. This is especially if you have a website servicing local customers.

Why Is This Important?

Imagine your business is in London. You service customers locally who visit your website. Now imagine your website is hosted in New York. Your customers are on their phone or computer, and click on a link. That click then has to travel all the way to New York, retrieve the data, then come all the way back to London again to appear on their screen. Why not just host it locally on a server in London?

This not only saves the data a long trip, but it also cuts down waiting time for the customer, and makes your site more responsive for your target audience. It massively improves TTFB and not only will customers see this, but your local Google algorithm will measure it too, boosting your local web rankings.

Any Recommended Web Hosts?

I won’t go into some huge hosting reviews, just give my recommendations. There are plenty of web hosting reviews out there but I will narrow it down to two hosts that I recommend for their performance and flexibility.

Firstly Kinsta. If budget does not matter (it’s $30 a month) then just go for it. It’s Nginx based. Everything on this page is already setup (plus a whole lot more) and it’s easily the fastest web host out there. Not only that but it’s based on the AWS / Google Cloud architecture and has Cloudflare built in. There is no messing about setting it up – it’s just ready to go out of the box.

Take a look at their servers on the Kinsta Website. You will attain the best pagespeed scores and website response times using Kinsta WordPress hosting and you can choose to host your website in any one of a multitude of countries to suit your needs.

The second option if you’d prefer a cheaper host with cPanel is A2 Hosting. Being US servers, they are best for USA based websites.

As long as you go for the turbo hosting, you will get good pagespeed scores. Hosting is super cheap but for once, I can recommend which is not normal for cheaper hosting. You have a little more to do here than at Kinsta, but Cloudflare is included which is amazing at this price.

You can see the A2 Turbo Packages on this page.

Enable Compression

You must enable GZIP compression on your web server. This compresses files by as much as 85% and can slash seconds off your website load time. This is one of the biggest instant pagespeed boosters there is.

How Do I Enable Compression?

Most hosts do have this enabled by default, but do a check here by typing in your domain name. If it’s not enabled, put the following code at the top of your .htaccess file:

<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE text/javascript
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE image/x-icon
AddOutputFilterByType DEFLATE image/svg+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/x-font
AddOutputFilterByType DEFLATE application/x-font-truetype
AddOutputFilterByType DEFLATE application/x-font-ttf
AddOutputFilterByType DEFLATE application/x-font-otf
AddOutputFilterByType DEFLATE application/x-font-opentype
AddOutputFilterByType DEFLATE application/vnd.ms-fontobject
AddOutputFilterByType DEFLATE font/ttf
AddOutputFilterByType DEFLATE font/otf
AddOutputFilterByType DEFLATE font/opentype
# For Olders Browsers Which Can’t Handle Compression
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
</IfModule>

Once it’s enabled, clear your server cache and WordPress cache, and retest your website using GTMetrix or Google Lighthouse.

Set An Efficient Cache Policy

When the browser caches your page’s static resources, it stores a local copy of these resources in its cache, making file retrieval much faster.

This is known as a caching policy and it simply tells the browser how long to store each file type for.

Longer cache policies instruct the browser to keep these files for longer (e.g., 1 year). This is important for resources that are unlikely to change frequently, like a logo image, or page fonts. Shorter cache policies are great for resources that change frequently, like CSS and JavaScript files.

How Do I Set My Cache Policy?

It’s similar to the step above. Depending on whether you have an Apache (cPanel) server, or NGINX one, just put the following code into your .htaccess file and all will be set.

No need for plugins to set cache policies!

Apache

<IfModule mod_expires.c>
ExpiresActive On
# Images
ExpiresByType image/jpeg “access plus 1 year”
ExpiresByType image/gif “access plus 1 year”
ExpiresByType image/png “access plus 1 year”
ExpiresByType image/webp “access plus 1 year”
ExpiresByType image/svg+xml “access plus 1 year”
ExpiresByType image/x-icon “access plus 1 year”
# Video
ExpiresByType video/webm “access plus 1 year”
ExpiresByType video/mp4 “access plus 1 year”
ExpiresByType video/mpeg “access plus 1 year”
# Fonts
ExpiresByType font/ttf “access plus 1 year”
ExpiresByType font/otf “access plus 1 year”
ExpiresByType font/woff “access plus 1 year”
ExpiresByType font/woff2 “access plus 1 year”
ExpiresByType application/font-woff “access plus 1 year”
# CSS, JavaScript
ExpiresByType text/css “access plus 1 year”
ExpiresByType text/javascript “access plus 1 year”
ExpiresByType application/javascript “access plus 1 year”
# Others
ExpiresByType application/pdf “access plus 1 year”
ExpiresByType image/vnd.microsoft.icon “access plus 1 year”
</ifmodule>

Nginx

Usually, Nginx servers are setup for this, but if not add the following snippet to your server block. You usually have to do do this at:

/etc/nginx/site-enabled/default

location ~* \.(jpg|jpeg|gif|png)$ {
expires 365d;
}
location ~* \.(pdf|css|html|js|swf)$ {
expires 30d;
}

Again, clear your server cache and WordPress cache, and retest your website using GTMetrix or Google Lighthouse. If everything goes to plan, your cacheing should be all setup.

Is That Everything?

That is all you need to worry about for now. There will be some additional writes to the .htaccess file, but this will be done by a few plugins as we go through the process.

What About Cloudflare?

Some hosts like A2 or Kinsta have it all setup for you – you just need to tick a box to get it going.

If your host does not have auto integration, then Cloudflare has a good integration guide you can read. For the everyday user, I like to recommend a host that does have auto integration.

Server Setup Complete!

Step 2: Install Plugins

Time To Get To The Nitty Gritty

Servers Explained

Host Close To Home

Hosting your website close to your customers is important, and the reasoning behind it is very similar to how a CDN works. This is especially if you have a website servicing local customers.

Why Is This Important?

Imagine your business is in London. You service customers locally who visit your website. Now imagine your website is hosted in New York. Your customers are on their phone or computer, and click on a link. That click then has to travel all the way to New York, retrieve the data, then come all the way back to London again to appear on their screen. Why not just host it locally on a server in London?

This not only saves the data a long trip, but it also cuts down waiting time for the customer, and makes your site more responsive for your target audience. It massively improves TTFB and not only will customers see this, but your local Google algorithm will measure it too, boosting your local web rankings.

Any Recommendations?

I won’t go into some huge hosting reviews, just give my recommendations. There are plenty of web hosting reviews out there but I will narrow it down to two hosts that I recommend for their performance and flexibility.

Firstly Kinsta. If budget does not matter (it’s $30 a month) then just go for it. It’s Nginx based. Everything on this page is already setup (plus a whole lot more) and it’s easily the fastest web host out there. Not only that but it’s based on the AWS / Google Cloud architecture and has Cloudflare built in. There is no messing about setting it up – it’s just ready to go out of the box.

Take a look at their servers on the Kinsta Website. You will attain the best pagespeed scores and website response times using Kinsta WordPress hosting and you can choose to host your website in any one of a multitude of countries to suit your needs.

The second option if you’d prefer a cheaper host with cPanel is A2 Hosting. Being US servers, they are best for USA based websites.

As long as you go for the turbo hosting, you will get good pagespeed scores. Hosting is super cheap but for once, I can recommend which is not normal for cheaper hosting. You have a little more to do here than at Kinsta, but Cloudflare is included which is amazing at this price.

You can see the A2 Turbo Packages on this page.

Enable Compression

You must enable GZIP compression on your web server. This compresses files by as much as 85% and can slash seconds off your website load time. This is one of the biggest instant pagespeed boosters there is.

How Do I Enable Compression?

Most hosts do have this enabled by default, but do a check here by typing in your domain name. If it’s not enabled, put the following code at the top of your .htaccess file:

<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE text/javascript
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE image/x-icon
AddOutputFilterByType DEFLATE image/svg+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/x-font
AddOutputFilterByType DEFLATE application/x-font-truetype
AddOutputFilterByType DEFLATE application/x-font-ttf
AddOutputFilterByType DEFLATE application/x-font-otf
AddOutputFilterByType DEFLATE application/x-font-opentype
AddOutputFilterByType DEFLATE application/vnd.ms-fontobject
AddOutputFilterByType DEFLATE font/ttf
AddOutputFilterByType DEFLATE font/otf
AddOutputFilterByType DEFLATE font/opentype
# For Olders Browsers Which Can’t Handle Compression
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
</IfModule>

Once it’s enabled, clear your server cache and WordPress cache, and retest your website using GTMetrix or Google Lighthouse.

Set Your Cache Policy

When the browser caches your page’s static resources, it stores a local copy of these resources in its cache, making file retrieval much faster.

This is known as a caching policy and it simply tells the browser how long to store each file type for.

Longer cache policies instruct the browser to keep these files for longer (e.g., 1 year). This is important for resources that are unlikely to change frequently, like a logo image, or page fonts. Shorter cache policies are great for resources that change frequently, like CSS and JavaScript files.

How Do I Set My Cache Policy?

It’s similar to the step above. Depending on whether you have an Apache (cPanel) server, or NGINX one, just put the following code into your .htaccess file and all will be set.

No need for plugins to set cache policies!

Apache

<IfModule mod_expires.c>
ExpiresActive On
# Images
ExpiresByType image/jpeg “access plus 1 year”
ExpiresByType image/gif “access plus 1 year”
ExpiresByType image/png “access plus 1 year”
ExpiresByType image/webp “access plus 1 year”
ExpiresByType image/svg+xml “access plus 1 year”
ExpiresByType image/x-icon “access plus 1 year”
# Video
ExpiresByType video/webm “access plus 1 year”
ExpiresByType video/mp4 “access plus 1 year”
ExpiresByType video/mpeg “access plus 1 year”
# Fonts
ExpiresByType font/ttf “access plus 1 year”
ExpiresByType font/otf “access plus 1 year”
ExpiresByType font/woff “access plus 1 year”
ExpiresByType font/woff2 “access plus 1 year”
ExpiresByType application/font-woff “access plus 1 year”
# CSS, JavaScript
ExpiresByType text/css “access plus 1 year”
ExpiresByType text/javascript “access plus 1 year”
ExpiresByType application/javascript “access plus 1 year”
# Others
ExpiresByType application/pdf “access plus 1 year”
ExpiresByType image/vnd.microsoft.icon “access plus 1 year”
</ifmodule>

Nginx

Usually, Nginx servers are setup for this, but if not add the following snippet to your server block. You usually have to do do this at:

/etc/nginx/site-enabled/default

location ~* \.(jpg|jpeg|gif|png)$ {
expires 365d;
}
location ~* \.(pdf|css|html|js|swf)$ {
expires 30d;
}

Again, clear your server cache and WordPress cache, and retest your website using GTMetrix or Google Lighthouse. If everything goes to plan, your cacheing should be all setup.

Is That Everything?

That is all you need to worry about for now. There will be some additional writes to the .htaccess file, but this will be done by a few plugins as we go through the process.

What About Cloudflare?

Some hosts like A2 or Kinsta have it all setup for you – you just need to tick a box to get it going.

If your host does not have auto integration, then Cloudflare has a good integration guide you can read. For the everyday user, I like to recommend a host that does have auto integration.

Server Setup Complete!

Step 2: Install Plugins

Time To Get To The Nitty Gritty

Server Setup – Pagespeed Guide