For AI agents: the complete documentation index is available at https://docs.ovhcloud.com/en/llms.txt, the full documentation bundle is available at https://docs.ovhcloud.com/en/llms-full.txt, and this page is available as Markdown at https://docs.ovhcloud.com/en/guides/web-cloud/web-hosting/cdn-how-to-use-cdn.md.

Speeding up your website with CDN

View as Markdown

Find out how to improve your website by reducing loading times on a Web Hosting plan using the CDN

Objective

If you want to improve user experience by speeding up your website, the most effective technique is to enable the CDN (Content Delivery Network) option. This allows you to cache static files, such as images, CSS and JavaScript, on the closest servers to your visitors.

Find out how to manage the CDN option on your Web Hosting plan.

Definition

How does a CDN work?

The CDN (Content Delivery Network) is literally a network dedicated to delivering content. It uses several servers around the world to display your website. The closer these servers are to your users, the faster your website performs for them.

In order for this to work, each server stores a part of your website in its cached memory. It is generally advised that you include so-called "static" files: images, JavaScript files and CSS, that help your website to run but are rarely modified.

Requirements


OVHcloud Control Panel Access

  • Direct link:
  • Navigation path: Web Cloud > Hosting plans > Select your web hosting plan

Instructions

Enabling the CDN option

Info

The CDN option is already included in the "Performance", "Agency", "Agency Plus" and "Agency Max" Web Hosting plans.

If the CDN option is not ordered or enabled on your Web Hosting plan

Click on the tabs below to view each of the 2 steps.

Step 1
Step 2

Go to the page, then select the relevant Web Hosting plan.

Web Hosting

If the CDN option is already enabled on your Web Hosting plan

Click on the tabs below to view each of the 4 steps.

Step 1
Step 2
Step 3
Step 4

Go to the page, then select the web hosting plan concerned.

Web Hosting

Why is it not possible to use a geolocated IP with the CDN option?

The CDN uses the principle of "IP Anycast". You do not request the same server depending on your geolocation, which is very efficient for reducing the loading time of your static files. Therefore, a geolocated IP address is not needed.
In terms of SEO (search engine optimisation), the website loading speed is more important than the geolocation of the IP addresses.

Managing your Shared CDN

Clearing the Shared CDN cache

It can sometimes be useful to clear the CDN cache, especially when you modify your static files. For example, when deploying a new version of your website. You can clear the cache for each of your domain names and subdomains.

Click on the tabs below to view each of the 3 steps.

Step 1
Step 2
Step 3

Go to the page, then select the web hosting plan concerned.

Web Hosting

Configuring Shared CDN options

Click on the tabs below to view each of the 4 steps.

Step 1
Step 2
Step 3
Step 4

Go to the page, then select the web hosting plan concerned.

Web Hosting
Creating a cache rule

Click on the tabs below to view each of the 5 steps.

Step 1
Step 2
Step 3
Step 4
Step 5

Go to the page, then select the web hosting plan concerned.

Web Hosting

Configuring CDN Security options

Click on the tabs below to view each of the 4 steps.

Step 1
Step 2
Step 3
Step 4

Go to the page, then select the web hosting plan concerned.

Web Hosting

Configuring CDN Advanced options

Click on the tabs below to view each of the 4 steps.

Step 1
Step 2
Step 3
Step 4

Go to the page, then select the web hosting plan concerned.

Web Hosting
Create an advanced caching rule

Click on the tabs below to view each of the 5 steps.

Step 1
Step 2
Step 3
**Step 4**
**Step 5**

Go to the page, then select the web hosting plan concerned.

Web Hosting

View CDN statistics and logs

To view CDN statistics and/or logs, please refer to our dedicated guide: "Web Hosting - View CDN statistics and logs".

How do I cache my files in the CDN?

Using a CMS

The main CMSs distribute several plugins that allow static files to be cached so that they are automatically included by the CDN. Others automatically configure static files by enabling an integrated caching to the CMS. For further information, please refer to the official documentation for the CMS or plugin that you use.

Without using a CMS

If you are not using a CMS, you can also use the CDN cache. To do this, you must add headers to the HTTP requests. There are several ways in which you can add these headers. One of the easiest ways is to define rules within a .htaccess file according to the file extensions.

1. # Cache images for 1 week
2. <FilesMatch "\.(jpg|jpeg|png|gif)$">
3. Header set Cache-Control "max-age=604800, public"
4. </FilesMatch>
5. 
6. # Cache JavaScript and CSS for 1 month
7. <FilesMatch "\.(js|css)$">
8. Header set Cache-Control "max-age=2592000"
9. </FilesMatch>
Warning

Caching by using HTTP headers results in caching within the CDN but also within your users’ browsers. Therefore, to prevent your visitors from seeing an older cached version, it is recommended that you rename the files with every new version.

Disabling the CDN option for a website

This action allows you to disable the CDN for one or more of your domain names or subdomains, without removing the CDN option from your web hosting.

Warning

Disabling the CDN option for a website requires changing the IP address to use to redirect your domain name to your Web Hosting plan. This change is done automatically if your domain name's active DNS zone is also managed from the containing your Web Hosting plan.

Otherwise, you will need to do two things:

  • Retrieve the default IP address of the cluster where your Web Hosting plan is located using our guide "Web Hosting: The IP addresses of our clusters".
  • Manually change the IP address in your domain name's active DNS zone, or contact your DNS zone provider to update it for you.

Modifying an entry in a domain name's active DNS zone will take between 4 and 24 hours to propagate fully. By the time this propagation finishes, a page containing the code 520 may appear randomly. This occurs because some parts of the DNS network still redirect requests to the CDN IP address linked to your Web Hosting plan.

Click on the tabs below to view each of the 4 steps.

Step 1
Step 2
Step 3
Step 4

Go to the page, then select the web hosting plan concerned.

Web Hosting

Cancelling the CDN option

This action will remove the CDN option from your entire Web Hosting solution.

Click on the tabs below to view each of the 3 steps.

Step 1
Step 2
Step 3

Go to the page, then select the relevant Web Hosting plan.

Web Hosting

Checking that your CDN is working

You can confirm that the CDN is active on your domain name via a terminal with the following command:

curl -i http://yourpersonaldomain.ovh/

If your domain name is being processed by the CDN, you will receive a result like the one below:

HTTP/1.1 200 OK
Date: Mon, 01 Jan 2020 00:00:00 GMT
Content-Type: text/html; charset=UTF-8
Set-Cookie: SERVERID12345=123456; path=/; max-age=900
Vary: Accept-Encoding
X-Request-ID: 123456789
X-CDN-Pop: rbx1
X-CDN-Pop-IP: 203.0.113.0/44
X-Cacheable: Cacheable
Accept-Ranges: bytes
Transfer-Encoding: chunked
X-IPLB-Instance: 12345

The "X-CDN" headers confirm that the domain is running through the CDN.

If the domain name is not running through the CDN, you will receive a result similar to the following:

HTTP/1.1 200 OK
Date: Mon, 01 Jan 2020 00:00:00 GMT
Content-Type: text/html; charset=UTF-8
Set-Cookie: SERVERID12345=123456; path=/; max-age=900
Server: Apache
X-Powered-By: PHP/7.1
Vary: Accept-Encoding
X-IPLB-Instance: 12345

The absence of the "X-CDN" header shows that you are not using a CDN.

Go further

For specialised services (SEO, development, etc.), contact OVHcloud partners.

If you would like assistance using and configuring your OVHcloud solutions, please refer to our support offers.

Join our community of users.

Was this page helpful?