Thymeleaf Static Resource Caching Issues
CSS or JavaScript changes don't appear after deployment. Browser caches old versions. Users see old styles or functionality.
Aggressive caching hides code updates.
Common Causes
- HTTP cache headers set too long
- Browser aggressively caches .css/.js files
- No cache busting (version strings in filenames)
- CDN cache not invalidated
- Service worker caching old resources
How to Fix It
Add version query string to resources: th:href=@{/css/style.css(v=${appVersion})}. Set cache headers: Cache-Control: no-cache for HTML, public max-age=3600 for static. Use content-hash in filename (style.a1b2c3d4.css). Disable cache in development: spring.web.resources.cache.period=0.
Real developers can help you.
You don't need to be technical. Just describe what's wrong and a verified developer will handle the rest.
Get HelpFrequently Asked Questions
How do I force browsers to refresh CSS?
Add query param: /css/style.css?v=1.0.1 and increment on release
Should I cache static files?
Yes, but with versioning. Use content hash for automated versioning