How to Set Up Browser Caching on a Small Website
Your PageSpeed report keeps flagging "Serve static assets with an efficient cache policy", and every returning visitor downloads your logo, stylesheet and fonts all over again on every page.

Your PageSpeed report keeps flagging "Serve static assets with an efficient cache policy", and every returning visitor downloads your logo, stylesheet and fonts all over again on every page. Setting up browser caching fixes both, and on most small websites it takes less than half an hour.
The catch is that a careless setup can leave visitors staring at an old version of your site for weeks. This guide shows the safe way to do it, with the exact values I use on small sites and how to check they work.
What browser caching does
When someone visits your site, their browser downloads every file the page needs: HTML, CSS, JavaScript, images and fonts. Browser caching tells the browser it can keep copies of some of those files on the visitor's device and reuse them for a set time instead of downloading them again.
The instruction comes from your server in a response header called Cache-Control. A header of Cache-Control: max-age=2592000 means "keep this file for 2,592,000 seconds", which is 30 days. During that time the browser loads it straight from disk, often in under 5 milliseconds, instead of fetching it across the network.
On a typical small business site, the CSS, scripts, fonts and logo add up to 300 KB to 1 MB per page. Caching them means the second page a visitor opens can load several times faster, and your server handles fewer requests.
Choose cache times by file type
Different files change at different rates, so they need different cache times. These are the values I start with:
| File type | Suggested max-age | Reason |
|---|---|---|
| HTML pages | 0 with no-cache, or up to 10 minutes | Content changes and must update quickly |
| CSS and JS with a version in the filename | 1 year, plus immutable | A new version gets a new filename |
| CSS and JS without versioning | 1 day to 1 week | Limits how long an old file can linger |
| Images | 30 days to 1 year | Rarely edited in place |
| Web fonts | 1 year | Almost never change |
One year is 31,536,000 seconds. The no-cache value is often misunderstood. It does not mean "do not store". It means the browser may keep the file but must check with the server before using it. If nothing changed, the server replies with a tiny "304 Not Modified" response and the browser uses its copy. For HTML, that is exactly what you want.
How to set up browser caching on your server
The method depends on how your site is hosted. Pick the one that matches yours.
Apache and most shared hosting
Most shared hosts run Apache, which reads a file called .htaccess in your site's root folder. Back it up first. Then add rules using the mod_expires module, for example a line reading ExpiresByType image/webp "access plus 1 year" for each image type, and ExpiresByType text/css "access plus 1 week" for stylesheets. Many hosts also let you add Cache-Control headers directly with mod_headers. Upload the file and test straight away, because a typo in .htaccess can take the whole site down with a 500 error. If that happens, restore the backup.
Nginx
On a VPS running Nginx, add a location block that matches static file extensions such as css, js, webp, jpg, png, svg and woff2, and inside it set expires 30d or expires 1y. Reload Nginx and check the headers.
WordPress
If you cannot edit server files, a caching plugin such as W3 Total Cache or LiteSpeed Cache, if your host uses LiteSpeed, has a browser cache section where you set lifetimes by file type. Turn on one caching plugin only. Two plugins fighting over the same headers cause odd bugs.
Static hosts and CDNs
Netlify and Cloudflare Pages read a plain text file called _headers, where you list a path pattern and the Cache-Control value for it. If your site sits behind Cloudflare, the Browser Cache TTL setting in the dashboard can override what your server sends, so check it matches your plan. Our guide to what a CDN is and whether a small site needs one explains how that extra layer fits in.
Why caching everything for a year is bad advice
A popular shortcut is to set every file, including HTML, to a one year max-age because it makes the PageSpeed warning disappear. I strongly advise against it.
Imagine you change your opening hours or fix a typo in your prices. A visitor who came last month still has the old HTML page in their cache and will not see the change for up to a year unless they clear their browser data. Most never will.
The same goes for CSS without versioning. Update your stylesheet and some visitors get the new HTML with the old styles, which can break your layout. The safe pattern is short or no-cache for HTML, and long caching only for files whose names change when their content changes, such as style.v3.css or app.4f2a1c.js. Many site builders and frameworks add these version strings automatically. Check whether yours does before setting a year.
It is also worth being honest about what caching cannot do. It only helps returning visitors and second page views. A first-time visitor gets no benefit at all, so it is no substitute for small images and a fast server. For that first visit, compressing images for a faster website and working on server response time matter far more.
Check that browser caching works
- Open your site in Chrome, press F12 and choose the Network tab.
- Click any CSS or image file in the list and look under Response Headers for Cache-Control. Confirm the max-age matches what you set.
- Navigate to a second page on your site. Files served from cache show "(memory cache)" or "(disk cache)" in the Size column instead of a file size.
- Run PageSpeed Insights again. The cache policy warning should list few or no files from your own domain.
Some files in that warning may belong to third parties, such as analytics or embedded maps. You cannot change their headers, so do not chase them. Our walk-through on reading a PageSpeed Insights report without panicking covers which warnings deserve your time.
Frequently asked questions
Does browser caching improve SEO?
Not directly, since Google's crawler does not reuse your cache the way visitors do. It helps indirectly by making repeat visits and multi-page sessions faster, which improves the experience for real users. Field data in Core Web Vitals can benefit as a result.
How long should browser cache last?
Use a short time or no-cache for HTML so content updates show up quickly. Versioned CSS, JavaScript and fonts can safely be cached for a year. Images usually sit well at 30 days to a year depending on how often you replace them.
How do I clear browser cache after updating my site?
You cannot clear visitors' caches yourself, which is why the cache times you choose matter. The reliable fix is to change the filename or add a version string whenever a cached file changes. For your own browser, a hard refresh with Ctrl and F5 reloads everything.
More in Performance
Performance
How to Fix a Slow Interaction to Next Paint Score
A client rang me in October because the booking form on her site felt broken on phones. Nothing was broken.
Performance
How to Load Web Fonts Faster on a Small Website
A small business site I looked at last month scored 94 on PageSpeed for desktop and 61 on mobile.
Performance
How to Reduce Server Response Time on a Small Website
You compressed every image, removed the slider and switched to a lighter theme, yet your speed report still shows a red warning...