Prompt
My assets are not updating after deployment, how do I fix CDN caching?
Latest observation
Oct 12, 2026
OpenAI APIWeb search: off
If your deployed assets aren’t updating, it’s usually because the CDN or browser is serving an old cached version. The fix depends on how your assets are named and cached.
Best fix: use cache-busting filenames
The most reliable approach is to make asset filenames change whenever the content changes, for example:
app.js→app.8f3a1c.jsstyles.css→styles.91bd2a.css
Most build tools can do this automatically:
- Webpack: use
[contenthash] - Vite: enables hashed filenames in production by default
- Next.js / Nuxt / CRA: typically handle this for production assets
Set different cache rules for HTML vs assets
A common setup:
- HTML: short cache or no cache
- Static hashed assets: long cache
Example headers:
Cache-Control: no-cache, must-revalidate
for HTML, and:
Cache-Control: public, max-age=31536000, immutable
for versioned assets.
If you’re using a CDN, make sure it respects origin changes
Check whether your CDN is:
- honoring your origin cache headers
- using query strings or path-based versioning correctly
- configured to purge/refresh when deploying
You may need to:
- purge the CDN cache
- invalidate specific paths
- set TTLs appropriately
Don’t forget browser cache
Even if the CDN is updated, the browser may keep old files if:
- the filename didn’t change
Cache-Controlis too aggressive for non-versioned files
Recommended deployment pattern
- Build assets with hashed filenames
- Serve HTML with low/no cache
- Serve hashed assets with long cache
- Purge CDN on deploy if needed
Example Nginx headers
location ~* \.(js|css|png|jpg|jpeg|gif|svg|woff2)$ {
add_header Cache-Control "public, max-age=31536000, immutable";
}
location ~* \.html$ {
add_header Cache-Control "no-cache, must-revalidate";
}
If you need a quick fix right now
- Purge/invalidate the CDN cache
- Hard refresh the browser
- Rename the asset files
- Check the response headers for
Cache-Control,Age,ETag, and CDN-specific headers likeX-Cache
If you want, tell me which CDN you use and your stack (Cloudflare, AWS CloudFront, Fastly, Netlify, Vercel, etc.), and I can give you the exact cache settings.