Caching
Caching stores previously retrieved content or resources so they can be reused without repeating the full request and delivery process.
It can reduce network traffic and make repeat visits substantially faster.
What It Means in Practice
A website may contain files that do not change very often, such as:
- Images
- Stylesheets
- JavaScript
- Fonts
- HTML documents
- API responses
Instead of downloading the same resource from its original source every time it is needed, a cached copy may be reused for a defined period.
How It Works
Caching can happen at several layers.
A browser may store resources locally on a user's device.
A content delivery network may cache a resource on servers closer to users.
Servers and applications may also cache generated pages, database results, or other expensive operations.
Rules determine how long cached content can be reused and when it needs to be checked for an updated version.
Why It Matters
Network requests take time.
If unchanged resources can be reused, the browser has less data to download and the server has less work to repeat.
Caching is particularly valuable on repeat visits and when the same resources are shared across multiple pages.
Common Problems
Common caching problems include:
- Static resources not being cached
- Cache durations that are unnecessarily short
- HTML cached longer than appropriate
- Old content remaining visible after an update
- Cache rules differing between the browser, server, and CDN
- URLs changing unnecessarily and preventing cache reuse
- Sensitive or user-specific content being cached incorrectly
Caching therefore requires more than simply turning it on.
How to Improve
Separate resources by how frequently they change.
Long-lived versioned assets such as CSS, JavaScript, fonts, and images can often be cached aggressively.
Frequently changing or personalized content needs more careful rules.
When troubleshooting, determine which caching layer is serving the response rather than assuming every stale page is a browser-cache problem.