Page Caching Explained: Browser, Server, and CDN
Caching means keeping a copy of something so you don't have to build or fetch it again. It's one of the most effective ways to speed up a website. There are several layers, each doing a different job.
Why caching helps
Without caching, every visit may require your server to run code, query a database, and assemble the page from scratch. With caching, the finished result is served immediately. This reduces server load and shortens response times. See what is TTFB.
The main types
Browser cache
The visitor's browser stores files such as images, CSS, and JavaScript so it doesn't download them again on later visits or other pages. You control this with caching headers. See browser caching explained.
Page cache (server-side)
Your server or a plugin saves the full HTML output of pages and serves that copy to visitors instead of generating it each time. This is especially valuable for CMS sites such as WordPress. See how to speed up a WordPress site.
CDN cache
A content delivery network stores copies of your files, and sometimes full pages, on servers around the world. Visitors get content from a nearby location. See what is a CDN.
Object and database cache
Behind the scenes, systems can store the results of frequent database queries or computed data so they don't have to be recalculated. This matters more for large or busy sites.
What to cache
- Static assets: images, fonts, CSS, JavaScript
- Pages that are the same for everyone, such as blog posts, service pages, and the homepage
What not to cache (or to cache carefully)
- Pages unique to each visitor, like account areas
- Shopping carts and checkout. Cached carts can show wrong contents or leak personal data. See how to speed up an online store
- Forms with security tokens that must be fresh
- Anything containing personal information
Good caching tools exclude these automatically, but verify them, especially on stores and membership sites.
Cache lifetime and updating
You choose how long copies are kept. Long lifetimes are efficient but risk showing stale content. Common approaches:
- Long lifetimes with versioned file names for CSS and JavaScript. When a file changes, its name changes, so browsers fetch the new one
- Shorter lifetimes or automatic purging for HTML pages, so edits appear soon
Most caching plugins and CDNs clear relevant caches when you publish changes. If an update doesn't appear, you may need to purge the page cache, the CDN cache, and refresh your own browser.
Troubleshooting stale content
- Hard-refresh your browser or try a private window
- Clear the site cache in your plugin or hosting dashboard
- Purge the CDN cache
- Wait a short while for settings to take effect
Caching and testing
When testing speed, check both a first uncached visit and a repeat visit. See how to test website speed.
Compression and protocols
Caching works well alongside gzip and Brotli compression and HTTP/2 and HTTP/3.
The bottom line
Cache assets in browsers and CDNs, cache public pages on the server, and never cache private or checkout content. Know how to clear caches when you update.