Skip to main content

On This Page

The Hidden Latency of 304 Not Modified: Why Frontend Engineers Must Own CDN Headers

2 min read
Share

These articles are AI-generated summaries. Please check the original sources for full details.

Frontend Engineers Should Care More About Infrastructure

Author Gavin Clive describes a CDN migration where missing Cache-Control headers led to a significant LCP regression detected in RUM data two weeks post-launch. While ETag validation via 304 Not Modified saves bandwidth, the resulting network round-trips caused rendering delays on high-latency 4G connections.

Why This Matters

In an ideal development model, 304 Not Modified is viewed as a successful cache hit because it prevents redundant data transfer. However, the technical reality is that every validation request requires a round-trip to the edge, which can block the Largest Contentful Paint (LCP) even if the payload size is zero. For users on mid-range devices or mobile networks, these aggregated validation spans create invisible latency that can compromise KPI cycles if frontend engineers do not verify the underlying infrastructure’s freshness policies.

Key Insights

  • LCP regression surfaced in RUM data two weeks after a successful CDN migration despite normal error rates and transfer sizes (2026).
  • Heuristic caching occurs when browsers calculate a short, unpredictable freshness window based on the gap between Last-Modified and the current date in the absence of explicit headers.
  • ETag vs. Cache-Control: ETag asks ‘has this changed?’ which requires a network request, while Cache-Control asks ‘do I need to ask right now?’ which can eliminate the request entirely.
  • Sentry traces can reveal a ‘page full of tiny validations’ where multiple 304 responses delay rendering even when bandwidth usage is optimized.
  • Conditional GET requests using If-None-Match still incur the cost of a round-trip before the browser can render the Largest Contentful element.

Working Examples

Explicit freshness policy providing seven days of cache freshness with a one-day window for background revalidation.

Cache-Control: max-age=604800, stale-while-revalidate=86400

Practical Applications

  • Use case: Applying long max-age directives to versioned assets and stable UI images to ensure browsers skip validation requests entirely during repeat visits.
  • Pitfall: Using long max-age on non-versioned URLs where the image content might change, creating a ‘footgun’ where users see stale content without a way to invalidate it.
  • Use case: Analyzing Sentry or DevTools waterfalls specifically for validation spans that occur before the LCP mark to identify missing infrastructure-level caching.
  • Pitfall: Assuming infrastructure migrations are ‘correct’ based solely on status codes like 200 or 304 without auditing the injected response headers.

References:

Continue reading

Next article

GhostPilot: Open-Source GPS-Denied Drone Navigation using Visual SLAM and AI

Related Content

Jul 27, 2026

"Refactor vs Rewrite Decision Tree for Engineers", "pubdate": "2026–07–27", "description": "Six-question framework evaluates whether incrementally refactoring legacy code outweighs strategic full-system rewrite.", "categories": ["Software Engineering", "Best Practices"], "mainheading": "A decision tree for grown engineers", "hook": { "sentences": [ "Edgar Nahama Alochi published an engineer’s guide distinguishing emotional rewrites from strategic ones.", "Most teams do not need rewrites — they need tests, clearer boundaries, smaller pull requests, and patience." ] }, "whythismatters": { "paragraph": "Engineering teams frequently conflate personal frustration with architectural necessity when considering rewrites versus refactors." +" While clean-slate approaches feel productive initially they erase hard-won production knowledge embedded in legacy code," +" often creating regression generators instead of improved systems." +" The economic cost of unnecessary rewrites includes months of slowed feature delivery plus reintroduction of bugs already fixed." +" Technical leaders must distinguish when change cost compounds structurally versus when discomfort stems only from poor naming or style." }, "keyinsights": [ {"fact_with_source_year": ": According to Alochi (July ॣ८६),ifasystemworksandgeneratesvalueyouarenonstaringatechnicalproblembutarevenueengine.Preferrefactoringinthatcase."},"]

...

Read article
Dec 4, 2025

The Invisible Architecture Behind Apps That Never Lag

A 3-hour bug fix turned into a 10-minute solution after mastering JavaScript’s event loop and microtask queue.

Read article
May 6, 2026

Why Stack Overflow Migrated from Ingress-NGINX to Istio Gateway API

Stack Overflow selects Istio after benchmarking Gateway API implementations against a 10,000 RPS target. The transition follows Ingress-NGINX retirement, revealing critical performance differences in route convergence and latency stability during updates.

Read article