Rebuilding the CloudFront and browser cache path for a 43.6% cut in daily transfer
Before adding anything, I read the request path. Cache keys and invalidation were matched to how each resource actually changes, and a Service Worker took repeat requests off the network entirely.
- CloudFront
- Service Worker
- Web Cache API
- React
- TypeScript
Specification
- Organisation
- Nudge Healthcare
- Period
- 2024
- Target
- Static asset delivery path of the web service
- Comparison
- Measured before and after at comparable traffic levels
- Role
- Request-path analysis, cache policy design, implementation, verification
Context
Network usage and CDN cost were high. The billing line alone could not tell me whether traffic had grown or whether the same bytes were being sent repeatedly.
Rather than adding a new solution, I inspected the request path and cache behaviour first. Identical static assets were being re-requested, and the cache keys did not match how often those resources actually changed.
Approach
I analysed the CloudFront cache structure, separating requests that hit at the edge from requests that reached the origin.
Cache keys and invalidation were re-cut along how each resource actually changes: assets that almost never change were given a different policy from assets that change on every deploy.
A Service Worker plus the Web Cache API took over browser-side caching, so repeat requests stopped crossing the network at all.
After deploying, I measured the same metrics again and compared daily transfer and egress cost at comparable traffic levels.
System
Nothing was added to the path — requests were made to stop earlier on it.
A browser request meets the Service Worker cache first; on a hit it never reaches the network. Only a miss goes to CloudFront, and only an edge miss reaches the origin.
Measured
Before: 417 GB/dayAfter: 235 GB/day−43.6%
182 GB less per day, compared at comparable traffic levels.
−30%+
The reduction in transfer showed up directly on the bill.
Move it yourself
Raise the hit rate and requests stop earlier. Only the ones that reach the origin are billed as transfer.
235GB/day
56%
417 GB/day and 235 GB/day are the measured values. Everything between them is a linear model for illustration, not a bill.
Boundaries
- These figures describe the static asset delivery path. They are a different measurement from the image delivery scale in project 04, which ran in the same account, and the two are never summed.
- Application logic on the origin was not part of this change.