TRENDING

TECHNOLOGY NEWS FROM AROUND THE WORLD

→
HTTP caching for live content: ETag, Cache-Control and freshness
Software Engineering · 2026
Software Engineering

HTTP caching for live content: ETag, Cache-Control and freshness

Balance page speed with fresh headlines by understanding browser, CDN and application caches.

Yazılımcının GünlüğüPublished: Nov 17, 20265 min read
JOIN THE DISCUSSION
✎ Write a comment
Reading progress0%

Why a cache issue resembles a data bug

An editor updates a headline in D1, but a visitor still sees the old version. The database may be correct while a browser, CDN, Worker or application cache serves an earlier response. Each layer has its own freshness and revalidation rules. Inspect Cache-Control, Age, ETag and available CDN headers to identify the likely source. Seeing different versions on two devices confirms the symptom but not the root cause. Hourly news refreshes are particularly sensitive: a page that repeatedly shows yesterday's headlines undermines editorial trust. Design caching by content type rather than applying one global lifetime to every resource.

Understanding Cache-Control directives

max-age describes freshness for a private cache, while s-maxage can set a separate lifetime in shared caches. public, private and no-store must reflect the response's sensitivity and reuse requirements. Never expose private session-dependent pages through an unrestricted shared cache. Versioned static images, by contrast, may be cached for longer periods because a new asset receives a new URL. Categorize resources by update frequency and whether the path itself represents a specific version. A news index may need frequent revalidation while immutable cover assets benefit from durable caching. Balance request overhead against the cost of stale information.

Service architectureConceptual sketch · summary of the article's technical flow

ETag and conditional requests

An ETag identifies a representation version. A client sends If-None-Match to ask whether its existing copy is still valid; a matching server may respond with 304 and no body. This can reduce bandwidth without forcing every request to re-download content. ETag generation must account for what the response actually contains, including user-specific differences where relevant. A database row version and an HTTP representation version are not always identical. Replacing bytes behind the same popular image URL can leave stale images in caches. Using content-derived asset paths often provides more predictable updates and simpler validation.

Conceptual workflow; adapt it to the actual application requirements.

When stale-while-revalidate makes sense

Some responses can be served from a slightly stale cache while a background refresh is requested. stale-while-revalidate offers this trade-off, but it should not become a universal default. A short delay in a historical category list may be acceptable; incorrect financial or security information may not be. Classify content by freshness needs, visitor impact and recovery behavior. Edge caches in different regions may not all update simultaneously. Measure cache hits, misses, revalidations and stale responses instead of assuming the configured TTL precisely describes what every user sees. Freshness and latency are two separate product metrics.

A post-deployment verification plan

Change a test headline and check the database write, API response, server-rendered HTML and browser view in sequence. Record the time until each layer reflects the new version. Verify that cover paths refer to the expected bytes and that old and new images do not get mixed. Purging an entire cache on every update is a blunt, potentially costly response. Prefer versioned assets and targeted invalidation when possible. Successful publication means the visitor actually receives the intended edition, not simply that the database update returned success. The same reasoning applies to newsrooms, dashboards and online stores.

A possible strategy for hourly headlines

Suppose a technology site refreshes its publisher feeds every hour. Fetching every RSS source on each visitor request would be unnecessary. Source ingestion can run on an hourly schedule while the rendered news index uses a shorter shared cache. For example, the public HTML may revalidate after tens of seconds while versioned image assets can remain cached much longer. These values are starting points for measurement, not universal rules. The key decision is to treat dynamic headlines and immutable media differently. Track the source's last fetch time, the D1 update time and when the public page displays the new edition as separate metrics. This makes delays between ingestion and visibility easier to diagnose.

Diagnose with the browser network panel

When an old image remains visible, inspect the exact request URL, response status and caching headers. Compare the CDN response age with the origin's current version. Try a versioned asset path to determine whether the problem follows the URL, while remembering that random query parameters are not a permanent architecture. If the issue appears only on mobile, consider service workers, browser history caches and device-specific resource variants. Avoid clearing the entire CDN before identifying which layer serves stale content. After a fix, verify the live page from more than one browser and network. Record response headers, timestamps and the visible edition to support later incident investigations.

Be the first reader ✎ Write a comment

Comments

No comments yet. Be the first to contribute.

What might reader discussion look like?Illustrative

These names, comments and editor replies are illustrative, not real visitor posts. Interactions are not saved. Use the real form below to contribute.

Casey Turner

Reading “HTTP önbellek stratejisi: ETag, Cache-Control ve haberin güncel kalması” raised this question for me: compatibility and debugging impact deserve review.

Sample editor reply

Editor note: Product claims and measured outcomes should be assessed separately. A small pilot with defined metrics is a useful first step.

Riley Thompson

We should also discuss maintenance cost. An easy rollout does not guarantee trouble-free upgrades.

Shannon Blake

I would start with a pilot and measurable success criteria rather than assuming a launch means proven value.

✎ Write a comment

Your first and last name will appear publicly alongside your comment.