A CDN only for images, video and downloads, or for the whole site: how to choose

Speed, Cache & CDN·· 70 views· 4 min read

The short answer: there are two ways to put a CDN to work. The whole site: the domain points at the CDN (through its nameservers or a DNS record), and all the site’s traffic passes through it. Files only: the site still goes straight to the server, and only images, CSS, JS, videos and downloads come from another address, usually a subdomain such as cdn.yourdomain, which the CDN fetches from the origin. Both are valid; what changes is what you touch and what can break. We do not sell a CDN: what follows applies to whichever CDN you choose, on an account of your own, opened directly with that provider.

The two side by side

Aspect Whole site Files only
What changes in DNS The nameservers, or the site’s record, point at the CDN. Only a new subdomain (a CNAME to the CDN). Everything else stays.
E-mail Stays out, but you must check the mail records do not go through the CDN. Not touched.
Protection and filtering For everything, pages and admin login included. For the files only. The site and the login still go straight to the server.
HTML caching Possible, with rules. No: files only.
What changes on the site Nothing in the addresses. File addresses switch to the subdomain (a plugin or a CMS setting).
Certificate The CDN issues one for the domain; the server’s stays. The subdomain needs a certificate at the CDN.
If the CDN fails The whole site is affected. Images and styles go missing, but pages still arrive.
Undoing it Put the nameservers or records back: switching the CDN off. Turn off the address rewriting on the site.

Setting up a files-only CDN

1 In the CDN dashboard, create the origin zone (many call it a “pull zone”) with your site’s address as the origin, for example https://www.yourcompany.com.
2 In the domain’s DNS, create the cdn subdomain as a CNAME to the address the CDN gives you. In cPanel this is done in the Zone Editor; see pointing a subdomain to another service.
3 Request the certificate for the subdomain in the CDN dashboard and wait until it is active before changing the site, or images will show as broken over https.
4 Rewrite the addresses on the site: on WordPress, LiteSpeed Cache has a CDN section where you enter the new address (the exact menu name changes with the version); other plugins do the same.
5 Check in the browser: F12, Network tab, files should come from the subdomain with no errors. If fonts fail with a CORS error, the CDN must send Access-Control-Allow-Origin for your domain: CORS errors.
6 Video: a general CDN delivers video files requested in pieces perfectly well, but it does not turn them into adaptive streaming. For a lot of video, a dedicated video service is usually better: videos on your website.
A CDN of this kind only holds what the server holds. Delete an image from the site and it disappears from the CDN once its lifetime runs out. Do not confuse this with moving files to external storage: then they are no longer on your hosting and no longer in the account backups. If you do that, backing those files up becomes your job: making and keeping your own backup.
How to choose: if the site itself is fast and the weight is in photographs and files, files only is enough, and you leave the nameservers alone. If you also want protection in front of everything and the server address hidden, go for the whole site. Either way, optimise images first (image optimisation and WebP) and measure before and after (testing whether it made a difference).

Deciding between the two and want a second opinion? Tell us the site address and where your visitors are.

Open a support ticket

SEE ALSO

What a CDN is, and when it makes a difference (and when it does not)

Putting a CDN in front of your site, step by step

Site with a CDN or without: how to test whether it made a difference

Pointing a subdomain to another server or service: A record or CNAME

CORS error between your front end and your API: how to fix it

Videos on your website: upload them or embed from a video service

RECOMMENDED PRODUCT

Web hosting with cPanel

Domain and SSL included, daily backups and the panel you already know. from $6.60/mo (3-year plan, with coupon)

See plans
Was this answer helpful? Your answer helps us improve this article.