Static vs Dynamic Caching
What Makes Content Static or Dynamic
Static vs dynamic content caching describes how easily a piece of content can be stored and reused. Static content is identical for every visitor, such as an image, a stylesheet or a JavaScript file. Dynamic content changes with each request or each person, such as a personalised product list, a shopping basket or a greeting that shows a visitor's name.
Static content is simple to cache. The copy stored for one visitor is correct for everyone, so a cache can serve the same file thousands of times. Dynamic content is harder. A cached copy might show the wrong name, a price for the wrong region, or an empty basket to a customer who has items in it.
Most real pages mix both. A product page has a fixed layout and images, plus a stock count or a login menu that varies. Caching the whole page as one unit therefore needs care.
How Edge and Fragment Caching Narrow the Gap
Two techniques make more of a dynamic page cacheable without sacrificing accuracy.
Edge HTML caching keeps whole HTML pages on a CDN edge server for a short time, even though the origin generates them. A news page that changes every few minutes can be served from the edge for one minute at a time. The origin then handles one request per minute for that page instead of one per visitor.
Fragment caching splits a page into parts and caches each part separately. The header, footer and article body can be stored, while a small block showing the visitor's name is generated fresh. Some platforms support this through Edge Side Includes, a standard that lets an edge server assemble a page from pieces.
Both approaches still need clear rules about what may be shared. Personal data should never sit in a copy served to other visitors. The mechanics of storing whole pages are covered in page caching, and rules for skipping the cache are in cache bypass cookies.
Frequently asked questions
Can a dynamic page ever be cached?
Yes, in parts. A page can be cached whole if its personal sections are loaded separately after the page arrives, or if the cache keeps different versions for different groups of visitors. Many sites cache the public version of a page and skip the cache for logged-in users. How much can be cached depends on how much of the page changes per visitor.
Are images and CSS files always safe to cache?
Usually yes, as long as their addresses change when their contents change. A browser or CDN keeps a copy for as long as the cache rules allow, which are set with Cache-Control headers. If a stylesheet changes but keeps the same name, visitors may see old styles until their copy expires. Cache busting solves this by giving each new version its own address.