Website caching and CDNs: what they are and do you need one?
Last updated
The short answer
Caching means keeping a ready copy of your pages and files so they don't have to be built or downloaded again. There are three kinds: the visitor's browser cache, a page cache on your server, and a CDN that keeps copies close to your visitors. Most small-business sites should tell browsers to keep images and fonts for a week and scripts and stylesheets for a day, switch on their platform's page caching, and consider a CDN if visitors come from far away or the host is slow.
The three kinds of caching
| Kind | Where the copy lives | What it speeds up |
|---|---|---|
| Browser cache | The visitor's own browser | Their second page and their next visit: images, fonts and scripts aren't downloaded again |
| Page cache | Your server or host | Every visit: a finished page is served instead of being built from the database each time |
| CDN | Servers around the world | Visitors far from your host, and busy periods, because files come from a nearby copy |
Browser caching is controlled by the Cache-Control header your server sends with each file (web.dev explains it well).
The Cache-Control settings to use
| What | Setting | Why |
|---|---|---|
| Pages (HTML) | no-cache | Stored, but re-checked on every visit, so visitors always get the latest page |
| Images and fonts | public, max-age=604800 | Kept for a week |
| Scripts and stylesheets | public, max-age=86400 | Kept for a day, so updates appear the next day at the latest |
| Files whose name changes when updated | max-age=31536000, immutable | Kept for a year: a new version gets a new name, so the old copy is never wrong |
| Account, basket and checkout pages | no-store | Not stored at all. private only keeps them out of shared caches such as a CDN: the visitor's browser may still store them. Also set your page cache and CDN to skip these pages. |
no-cache doesn't mean "don't cache": as MDN puts it, the copy can be stored but "must be validated with the origin server before each reuse". no-store is the one that means nothing is kept.
How to set it, by platform
- WordPress: a caching plugin (or your host's built-in caching) handles page caching and usually the browser-cache rules too. Use one caching plugin, not several.
- Apache hosting (including most WordPress hosting): rules like these in
.htaccess:
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/webp "access plus 1 week"
ExpiresByType image/jpeg "access plus 1 week"
ExpiresByType image/png "access plus 1 week"
ExpiresByType image/svg+xml "access plus 1 week"
ExpiresByType font/woff2 "access plus 1 week"
ExpiresByType text/css "access plus 1 day"
ExpiresByType application/javascript "access plus 1 day"
</IfModule>- Windows hosting (IIS): a
clientCachesetting inweb.configfor static files; the slow-site guide shows it. - nginx:
expiresoradd_header Cache-Controllines in alocationblock for images, fonts, CSS and JS. - Shopify, Wix and Squarespace: caching and a CDN are built in and managed for you.
Do you need a CDN?
A CDN is worth it when:
- Your visitors are spread across a country or the world, far from where your site is hosted.
- Your pages are heavy with images or video.
- Your host is slow to respond, or busy periods slow the site down.
If your visitors are local and your host is close and quick, good browser and page caching may be enough. Many hosts include a CDN, and services such as Cloudflare put one in front of any site. A CDN also helps the Largest Contentful Paint speed score by getting the main image to the browser sooner.
Mistakes to avoid
- Caching pages for a long time: visitors then see old prices or opening hours. Re-check pages with
no-cache; keep long times for files. - Caching logged-in pages: mark them
no-store, and keep them out of the page cache and CDN. - Two caching plugins at once, which can conflict and serve broken pages.
- Forgetting to clear the cache after a site update: most caching plugins and CDNs have a "purge" button. Purging doesn't reach copies already in visitors' browsers; a file published under a new name does.
Checklist
- Images and fonts are sent with a week-long Cache-Control.
- Scripts and stylesheets are kept for at least a day.
- Pages are re-checked on each visit (no-cache).
- Account, basket and checkout pages are no-store, and skipped by the page cache and CDN.
- Page caching is on, with one caching plugin at most.
- A CDN is in place if visitors are far away or the host is slow.
Questions people ask
- What is website caching?
- Keeping a ready copy of a page or file so it doesn't have to be built or downloaded again: in the visitor's browser, on your server, or on a CDN near the visitor. It makes repeat visits and busy periods much faster.
- Will caching show visitors an old version of my site?
- It can. Pages themselves are re-checked on each visit, but a browser may keep an image, stylesheet or script until its time runs out. When you change a file, publish it under a new name (many site builders and plugins add a version number for you) and make the page point to it. Purging a CDN doesn't clear copies already held in visitors' browsers.
- Is Cloudflare a CDN?
- Yes. It is one of several CDN services, and many web hosts include a CDN with their plans. Check what your host offers before adding another.
- Should I cache pages for logged-in customers?
- No. Pages showing account details, baskets or checkout should be marked no-store and kept out of the page cache and CDN, so one customer never sees another's page.
What the free scan checks for this
These are the FocalScore checks that cover this guide's subject. Each one in your report says what it found, shows the evidence and gives the fix.
- No caching / no CDN
- Your images, fonts and files are cached long enough
- Time to First Byte (TTFB)
- Text files are compressed
- Total page weight
Sources
Last checked . Documentation, settings and rules change; if one of these pages now says something different, it is right and this guide is out of date. Tell us at info@focalscore.com.
More guides
- How to get your business recommended by ChatGPT and other AI assistants
- Why can't ChatGPT see my website? 5 reasons and how to fix them
- robots.txt for small businesses: what to allow, what to block
- What is IndexNow, and why does it matter for your website?
- The pages every small-business website needs
- How to turn more website visitors into enquiries
- Why your site is slow, and what to fix first
- How your business shows up in Google: titles, descriptions and headings
- One address for each page: www, https, canonical tags and redirects
- A sitemap for any site, including one built by hand
- Making your site usable by everyone
- Making your site work on a phone
- Security headers for a small business website: what to set, by platform
- Stop people sending email as your business: SPF, DKIM and DMARC
- Cookies and consent: what your site sets and when you need a banner
- How your links look when people share them
- Getting your business details right for Google Maps and AI assistants
- What is GEO (generative engine optimization)? A plain-English guide
- llms.txt: what it is, and does your business need one?
- AI crawler blocked? Fixing 403, 404 and 405 errors for GPTBot, ClaudeBot and PerplexityBot
- How to see if ChatGPT visits your website
- GEO vs SEO: what's the difference for a small business?
- AI SEO for small businesses: where to start
- Answer engine optimization (AEO), explained
- SPF record: what it is and how to set one up
- DMARC record: what it is and how to set one up
- DKIM record: what it is and how to set it up
- Why do my emails go to spam? How to check SPF, DKIM and DMARC
- Content Security Policy (CSP) for a small business website
- security.txt: what it is and how to add one to your site
- What is DNSSEC, and should you turn it on?
- CAA record: what it is and how to set one up
- Largest Contentful Paint (LCP): why your page feels slow and how to fix it
- Local business schema: structured data for a small business, with a template
- Accessibility statement: what to write, with a template
- Trust badges and testimonials that help a website win customers
- Why isn't my website showing up on Google? How to get it there
- Google Business Profile: a checklist to make it match your website
- Custom 404 page: what a good one does, and the soft 404 trap
- Meta description length: how long should it be?
- Image alt text: what to write, with examples
- Broken links: how to find and fix them on your website
- Website audit checklist: a free check-up for a small business site
- Why does my website say 'Not secure'? How to fix it
- Is my website ADA compliant? An accessibility checklist for US small businesses
- Has my website been hacked? How to check, and what to do next
- Core Web Vitals explained: LCP, INP and CLS in plain English
- Interaction to Next Paint (INP): why your site feels slow to tap, and how to fix it
- Cumulative Layout Shift (CLS): why your page jumps while it loads, and how to stop it
- What should a small business privacy policy include? A checklist
- Contact form emails not arriving? Find where enquiries get lost
- Website monitoring: catch downtime, broken enquiries and expired certificates
- Moving or redesigning your website: a checklist so nothing gets lost
- How to audit a WordPress website: a checklist for owners
- Why isn't my business showing up on Google Maps?
- Does ChatGPT recommend your business? How to check, and how to fix what it gets wrong
- Why isn't my website getting customers? A three-question diagnosis
- How to get more Google reviews without breaking Google's rules
- Google Search Console for a small business: set it up and read the three reports that matter
- Who owns your domain and website? How to check, and how to get them back
- How to show up in Google AI Overviews and AI Mode: what Google's own guide asks for
- What is a good PageSpeed score? What the number means for a small business site
- How much should a small business website cost, and what to check before you pay the final invoice
- Is my website down, or is it just me? What to check, in order
- Is my SEO company actually doing anything? How to check, and how to spot a scam email
- Should I redesign my website or just fix it?
- Does your website still need an FAQ page now that Google's FAQ rich results are gone?