Why a CDN Is a Mathematical System
Why is mathematics important in content delivery networks? A CDN places copies of web objects near users, decides when a cached copy is reusable, routes requests among locations and protects origins from repeated work. Beneath a fast image or video are ratios, latency paths, expiry functions, popularity distributions, queueing and controlled invalidation.
The importance of mathematics appears when a cache hit saves hundreds of milliseconds, a popular object overwhelms an origin after expiry, two users see different versions during a rollout, or a purge reaches most but not all edge locations. A CDN does not create zero distance or perfect global freshness. It exchanges storage and temporary staleness for lower repeated cost.
This article uses current HTTP caching standards, especially RFC 9111, and RFC 5861 stale-response controls, checked on 10 October 2026. CDN products add their own routing, tiering and purge features. Examples explain durable mechanisms, not one provider's configuration.
Quick Reading Routes
- Students: begin with cache keys, hit ratios, latency sums and expiry.
- Parents: read the everyday analogies, safe projects, misconceptions and guidance.
- Teachers: use the workload simulations, purge timelines and percentile investigations.
- Career explorers: connect this topic to web engineering, cloud platforms, media delivery, cybersecurity and reliability.
Test only systems you own or are authorised to use. Purges, load tests and large downloads can affect real users and bills.
The Basic Choice Is Edge or Origin
A request follows a path
A browser asks for an object through a hostname. A nearby edge location checks whether its cache holds a response matching the request's cache key and whether that response may be reused. A usable copy becomes a hit. Otherwise the edge obtains or validates a response upstream.
The path is conditional: hit and miss requests do different work.
Latency is a weighted expectation
Let hit probability be h, hit latency Lh and miss latency Lm. Expected latency in a simple two-state model is `E[L] = hLh + (1-h)Lm`.
If h = 0.9, Lh = 20 ms and Lm = 220 ms, expected latency is 40 ms. Raising h to 0.95 gives 30 ms. Five percentage points save 10 ms in the model because misses are expensive.
Means are not user guarantees
The expected value hides the distribution. Hits may range from 5 to 80 ms; misses may include rare multi-second origin delays. Monitor percentiles and error rates by region and object class.
One average across all traffic can conceal a weak country, device type or large-object path.
Cache Keys Define Sameness
The URL is only the beginning
A cache key commonly includes scheme, host and path, and may include query parameters or selected request headers. Responses using `Vary` can depend on header values.
Two requests are reusable together only when the cache's equivalence rule says they are the same representation.
Too narrow a key serves wrong content
If language affects the response but the key ignores language, a cached English page might be served to a Chinese-language request. This is a correctness failure, not just a performance issue.
Personalised or authorised responses require especially careful controls.
Too broad a key fragments reuse
If every irrelevant tracking parameter enters the key, logically identical objects occupy separate entries. Hit ratio falls and storage is wasted.
Key design is a partition of the request space: combine requests that can safely share, separate those that cannot.
Freshness Is a Time Inequality
Age is compared with lifetime
HTTP caches calculate response age and freshness lifetime from headers and stored metadata. In a simplified statement, a stored response is fresh while `current_age < freshness_lifetime`.
Once stale, it cannot be reused normally unless validation succeeds or an allowed stale rule applies.
Cache-Control expresses policy
Directives such as `max-age`, `s-maxage`, `no-cache` and `no-store` have specific meanings in RFC 9111. `no-cache` does not mean “never store”; it means the response must be successfully validated before reuse, subject to the standard.
Precise vocabulary prevents dangerous shortcuts.
Clocks and transit contribute to age
Age is not merely time since the edge wrote a file. HTTP's age calculation accounts for message timing and upstream Age information.
A multi-tier cache must not reset an old response to newborn merely because it crossed another layer.
Validation Saves Bytes Without Ignoring Change
Conditional requests ask whether content changed
An edge can send an entity tag with `If-None-Match` or a last-modified time with `If-Modified-Since`. If the representation is unchanged, the origin can reply with a 304 response without resending the full body.
Validation still uses an origin round trip, so it saves transfer more than distance.
Strong and weak validators differ
Entity tags can express representation identity according to HTTP rules. Weak validators permit some semantic equivalence where byte-for-byte identity is not required.
Applications should not invent comparisons that contradict the validator semantics.
A worked bandwidth example
Suppose a 5 MB file is validated 100,000 times. Full transfer would move about 500,000 MB. If compact 304 exchanges average 1 KB, response bodies and metadata are roughly 100 MB plus protocol overhead.
The origin still processes validation. Caching moves cost; it does not make work vanish.
Hit Ratio Has Several Denominators
Request hit ratio counts requests
If H requests hit and M miss, request hit ratio is `H/(H+M)`. With 950,000 hits and 50,000 misses, it is 95%.
This treats a 1 KB icon and a 1 GB video equally.
Byte hit ratio weights size
Byte hit ratio is bytes served from cache divided by total bytes served. A few large misses can make it much lower than request hit ratio.
Use both when bandwidth and origin egress matter.
Origin offload counts avoided work
Some hits still contact an upper cache; some misses are collapsed so only one origin request occurs. Origin-offload ratio should use actual origin requests or bytes, not assume every edge miss reaches origin.
Name the metric and denominator before celebrating it.
Popularity Is Usually Skewed
A small catalogue receives most demand
Web-object popularity often resembles a heavy-tailed or Zipf-like distribution: a few objects are extremely popular and many are rarely requested. Caching the head can capture much demand with limited space.
If the top 1% of objects receive 70% of requests, an edge that retains them can achieve strong request hits even without storing the entire catalogue.
Long-tail storage has low reuse
An object requested once and never again gains no second hit. Storing it may evict something useful.
Admission policies can require evidence of reuse before promoting an object to scarce fast cache.
Events reshape popularity
Breaking news, ticket launches and software releases create sudden hot objects. Yesterday's ranking may fail today.
Eviction and admission should adapt without letting one burst destroy all stable working-set entries.
Eviction Is an Online Decision
Capacity is finite
When a new object arrives and storage is full, the cache chooses something to remove. Least-recently-used, least-frequently-used and size-aware policies represent different predictions about future requests.
The future is unknown, so eviction is an online optimisation problem.
Object size changes value density
One 1 GB video occupies the space of a million 1 KB objects. The video may still deserve storage if it is popular and expensive to refetch.
A useful score can consider frequency, recency, size and miss cost rather than only one dimension.
Churn wastes bandwidth
If objects are repeatedly inserted and evicted before reuse, the cache thrashes. Measure evictions, object lifetime and second-hit probability.
More storage can help, but key fragmentation or poor admission may be the real cause.
Misses Can Collapse Into One Fetch
Simultaneous demand should not stampede
When a popular item expires, thousands of edge requests may arrive before the first refresh completes. Sending every request to origin creates a thundering herd.
Request coalescing lets one fetch proceed while others wait or use an allowed stale copy.
Queueing defines the wait
If one refresh takes 200 ms and 10,000 requests arrive during it, coalescing can reduce origin work from 10,000 fetches to one for that key at that edge. Waiting clients still consume connections and memory.
Bounds and timeouts protect the edge if the refresh stalls.
Jitter spreads scheduled expiry
If many objects receive the same lifetime at one deployment, they can expire together. Adding controlled random jitter spreads refreshes over a window.
Randomness is used to reduce synchronisation, not to make policy unknowable.
Stale-While-Revalidate Trades Freshness for Speed
Stale content can serve during refresh
RFC 5861 defines `stale-while-revalidate`, allowing a cache to serve a stale response for a specified interval while asynchronously validating it.
Users receive low latency; the background request updates the cache.
The stale window is bounded
The directive does not authorise permanent staleness. Let freshness lifetime be F and stale-while-revalidate allowance S. A simplified reuse horizon is F + S, subject to HTTP rules and successful operation.
Choose S according to how harmful temporary staleness is.
Suitability depends on content
A news thumbnail may tolerate a minute-old version. A revoked safety notice or account balance may not.
Classify content by freshness risk instead of applying one directive everywhere.
Stale-If-Error Supports Resilience
An old response may be better than failure
RFC 5861 also defines `stale-if-error`, permitting stale reuse for a bounded period when an error occurs. A stable documentation page can remain available during an origin outage.
This is a controlled availability choice.
Some stale data is dangerous
Inventory, access policy, prices and emergency information can become harmful when old. The response owner should decide policy with domain knowledge.
“Available” is not automatically “correct enough.”
Observe stale service explicitly
Dashboards should distinguish fresh hits, validated hits, stale-while-revalidate and stale-if-error. Otherwise an origin incident can be masked until the stale window ends.
Resilience without visibility becomes delayed surprise.
Invalidation Is a Distributed Operation
Expiry is passive; purge is active
Expiry waits for freshness lifetime to end. Invalidation sends instructions to remove or mark content unusable before natural expiry.
Active purge helps urgent changes but requires communication to many cache nodes.
Completion is a distribution
If 99% of edges purge within 2 seconds and the final 1% take 30 seconds, “purged in 2 seconds” is incomplete. Report percentiles, maximum known delay and failures.
A client routed to a slow edge can still see the old object.
Versioned URLs avoid some purges
Static assets can include a content hash in the filename. New content receives a new URL, while old cached objects remain correct for their names.
HTML that points to the new asset still needs an update path. Versioning moves invalidation to a smaller control surface.
Purge Scope Affects Cost and Risk
Exact-key purge is precise
Removing one known cache key limits collateral misses. It can fail when variants or normalised forms are overlooked.
Inventory the actual key dimensions.
Tag or prefix purge is broader
Surrogate keys or tags group related objects, such as every page containing one product. A tag purge is convenient but can evict a large working set.
Estimate the number of affected entries and refill load.
Purge-everything is a capacity event
Clearing an entire cache converts future hits into misses. Origin and upper tiers must absorb the refill.
Plan the miss storm before using a global button.
Tiered Caches Multiply Reuse
Edge and shield layers have different audiences
An edge cache serves one region; an upper-tier shield aggregates misses from many edges. An edge miss can become a shield hit, avoiding the origin.
The path has states: edge hit, shield hit and origin fetch.
Expected latency uses conditional probability
Let edge hit rate e, shield hit rate s conditional on edge miss, and latencies Le, Ls, Lo. Expected latency is `eLe + (1-e)[sLs + (1-s)Lo]`.
With e=.8, s=.75, Le=15, Ls=60 and Lo=250 ms, expectation is 27.5 ms.
Upper tiers can become bottlenecks
Aggregating traffic protects origin but concentrates misses. Size capacity, connections and failure isolation accordingly.
One shield region can create a common dependency for many edges.
Geographic Routing Uses Distance Proxies
Nearest is not always lowest latency
Geographic distance correlates with propagation delay, but network peering and congestion change routes. A physically nearer edge can have a worse path.
Routing systems use measurements and network information, not a globe alone.
Anycast changes the path dynamically
With anycast, several locations advertise the same address and routing selects a path. The selected location can change after network events.
Users in one city may reach different edges over time.
Health must enter the objective
Low latency to an overloaded edge is not useful. Routing balances path delay, capacity, health and policy.
A weighted score is a model; monitor whether real users improve.
Video Delivery Adds Segment Mathematics
Adaptive streaming divides content
Video is split into timed segments at several bitrates. The player estimates throughput and buffer to choose a representation.
A 6 Mbps stream consumes roughly 0.75 MB per second before overhead. A four-second segment is about 3 MB.
Buffer prevents immediate stalls
If playback consumes one second per second while downloads supply 1.2 seconds of video per second, buffer grows 0.2 seconds per second. If supply falls to 0.5, it shrinks 0.5.
The conservation equation resembles a queue in reverse.
Cacheability depends on shared segments
Popular identical segments receive strong reuse. Personalised manifests or encryption keys can fragment keys and reduce hit ratios.
Design must preserve security while understanding its cache cost.
Range Requests Change the Unit of Reuse
Large files are often requested in pieces. HTTP range requests let a client ask for a byte interval instead of downloading the entire object. That is useful when a user resumes a download, seeks within media or needs only part of a large archive. It also makes cache accounting more subtle because the reusable unit may be a whole representation, a stored range or a collection of fragments.
Partial content has coordinates
Suppose a 100 MB file is numbered from byte 0 to byte 99,999,999. A request for bytes 20,000,000 through 29,999,999 asks for 10 MB, not 9,999,999 bytes, because both endpoints are included. Off-by-one errors matter. They can produce gaps, overlap or incorrect content-length values.
If ten users request the same 10 MB interval, an edge that stores and reuses that interval may prevent 90 MB of repeated origin transfer after the first miss. If every user asks for a different interval, however, the nominal request hit ratio can remain low even though all requests refer to the same URL. The useful denominator has shifted from objects to byte regions.
Fragment strategies have trade-offs
A cache can fetch the entire file after one partial request, fetch only the requested range, or combine stored fragments. Whole-object fetching may improve later reuse but wastes bandwidth if most visitors need only a small slice. Range-only fetching is economical immediately but can create fragmented storage and more origin requests. Combining fragments needs careful validation so pieces from different versions are never assembled together.
The decision can be written as an expected-cost comparison. If the probability that later requests need the rest of the file is q, the expected benefit of fetching ahead should be weighed against unused bytes, storage occupancy and origin capacity. There is no universal threshold: file size, popularity, change frequency and transfer price all change it.
Compression and Content Negotiation Create Variants
The same logical page can have several encoded representations. A client may accept Brotli, gzip or an uncompressed response. Images may vary by format or device hints. Languages and accessibility settings can also change representation. Each meaningful difference must enter the cache key or a validated variant mechanism; otherwise one user can receive a representation intended for another.
Compression changes byte-hit arithmetic
Assume an origin page is 200 kB uncompressed, 70 kB with gzip and 55 kB with Brotli. If 60% of requests use Brotli, 35% use gzip and 5% are uncompressed, the average transferred size is 0.60 × 55 + 0.35 × 70 + 0.05 × 200 = 67.5 kB.
Serving 1,000 requests therefore transfers about 67.5 MB before protocol overhead. Calling every response a 200 kB save would exaggerate the benefit. Capacity forecasts need the actual representation mix.
More variants dilute each pool
If a resource receives 100 requests per minute but is divided evenly among five variants, each cache entry sees only about 20 requests per minute. With a two-minute lifetime, a variant may still be reused many times; with a ten-second lifetime, some variants may expire before a second request. Variant design therefore interacts with arrival rate and TTL.
The lesson is broader than CDNs: finer personalisation usually improves fit but reduces statistical pooling. Students see the same tension when splitting a survey into many tiny subgroups. More detail is not automatically more knowledge if each group becomes too sparse.
Cache Warming Is an Allocation Problem
After deployment, purge or regional expansion, a cache begins cold. Operators sometimes prefetch selected objects so the first real visitors do not all pay miss latency. Warming every possible object is usually wasteful, so the task becomes a ranked allocation problem.
Popularity and size compete
A simple warm score might estimate avoided origin bytes as expected requests × object size × probability the object would otherwise miss. Another score might prioritise avoided user delay. These objectives can disagree. A large software package may dominate bandwidth, while a small configuration file may sit on the critical path and dominate page-start latency.
Suppose object A is 50 MB and expected to receive 20 requests, while object B is 200 kB and expected to receive 5,000 requests. Warming A avoids at most about 950 MB after the first unavoidable copy if all requests arrive within its useful lifetime. Warming B avoids roughly 999.8 MB and may improve many more sessions. A size-only rule would choose badly.
Forecast error must be priced
Historical popularity is evidence, not certainty. A newly announced file may surge; yesterday's viral object may vanish. A practical warming plan keeps room for uncertainty, monitors realised reuse and stops prefetching objects whose benefit does not materialise. This is a small example of online learning: act using an estimate, observe the result and update the policy.
Experiments Need Cohorts and Guardrails
A CDN policy change should be evaluated with more than a before-and-after screenshot. Traffic composition, time of day, launches and failures can all change simultaneously. A controlled rollout assigns comparable cohorts to old and new rules, then measures both desired outcomes and harms.
Define the estimand first
The estimand might be the change in median page latency for eligible requests, the change in origin bytes per request, or the probability that a user receives content older than an agreed limit. Each answers a different question. Choosing the metric after seeing results invites selective interpretation.
If the treatment cohort has mean latency 118 ms and the control has 125 ms, the observed difference is −7 ms. That is not enough by itself. Engineers also inspect sample size, variability, geography, cache state and confidence intervals. A tiny but statistically detectable change may be operationally irrelevant; a useful improvement may still be uncertain in a small region.
Guardrails protect correctness
Useful guardrails include origin error rate, stale-response rate, purge completion time, authentication failures and cross-user content incidents. A policy that improves hit ratio by caching private responses is not a success. Multi-objective evaluation makes that explicit: performance is valuable only within correctness, privacy and reliability constraints.
A Complete Worked CDN Scenario
Consider a learning site that serves a 400 kB lesson page and a 6 MB shared diagram pack. In one hour, 12,000 page requests and 2,000 pack requests arrive. The page has a 92% request-hit ratio; the pack has a 70% request-hit ratio. Cached pages average 45 ms, page misses average 230 ms, cached packs average 80 ms and pack misses average 900 ms.
For pages, misses equal 12,000 × 0.08 = 960. Origin bytes for those page bodies are approximately 960 × 400 kB = 384 MB. For packs, misses equal 2,000 × 0.30 = 600, producing about 3,600 MB of origin body transfer. The page has the better request-hit ratio, yet the pack dominates origin bandwidth.
Expected page latency is 0.92 × 45 + 0.08 × 230 = 59.8 ms. Expected pack latency is 0.70 × 80 + 0.30 × 900 = 326 ms. If engineers improve the pack hit ratio to 85% without changing conditional latencies, expected pack latency becomes 0.85 × 80 + 0.15 × 900 = 203 ms. That 123 ms reduction applies to pack requests, not automatically to the whole lesson experience.
Now add freshness. If the pack changes once per day and uses versioned URLs, a long lifetime is relatively safe because a new version gets a new key. If the lesson page contains timetable notices under a stable URL, a long lifetime can expose stale information. The worked example therefore ends where real design begins: combine ratios, bytes, latency and update semantics instead of optimising a single number.
Security and Privacy Constrain Caching
Private responses must not leak
Shared caches must respect authorisation and cache directives. A response containing one user's information must not be reused for another because a key omitted identity.
Correctness and privacy override hit ratio.
Cache poisoning attacks the key and response
If an attacker can make a cache store a malicious response under a victim key, many users receive it. Input normalisation, header handling and origin validation matter.
Security review should model which request variations influence the origin.
Logs reveal behaviour
CDN logs can contain IP addresses, paths and identifiers. Sampling, retention and access controls should minimise privacy risk.
Performance measurement is not permission for unlimited surveillance.
Capacity Planning Counts Miss Amplification
Origin sees the residual demand
For request rate λ and origin-offload fraction o, simple origin rate is `λ(1-o)`. At one million requests per second and 99.9% offload, origin still sees about one thousand per second.
A fall to 99% multiplies that to ten thousand.
Regional failures move traffic
If one edge region carrying 20% of demand fails, surviving regions and origin may receive redistributed load. Capacity should include failure scenarios, not only normal averages.
The new route can have higher latency and lower hit warmth.
Cold starts are deliberate tests
Deploying a new edge or purging creates a cold cache. Estimate fill bytes, upstream connections and time to stable hit rate.
Warm-up traffic should not become an uncontrolled denial of service against the origin.
Common Misconceptions to Correct
“A CDN makes every request local”
Only reusable cached objects hit locally. Misses, validation and uncacheable responses travel upstream.
“A 99% hit ratio means 99% bandwidth saved”
Request and byte hit ratios differ. The missed 1% can contain the largest objects.
“Long TTL is always faster”
Long freshness improves reuse but extends ordinary staleness. Content risk determines the trade-off.
“Purge is instantaneous everywhere”
It is a distributed operation with a latency distribution and failure cases.
“Stale content is always wrong”
Bounded stale reuse can be a deliberate resilience policy for suitable content. It is dangerous for other content.
“The closest edge is always best”
Network paths, peering, capacity and health matter alongside geography.
How Students Can Build Transferable Skill
Simulate hits and misses
Create 1,000 requests with object IDs drawn from a skewed distribution. Implement a small least-recently-used cache in a spreadsheet or program. Change capacity and measure request and byte hit ratios.
Explain why the ratios move differently.
Build an expiry timeline
Give four edges different fetch times and one TTL. Change the origin object and calculate when each edge naturally refreshes.
Then add purge delays and compare passive and active convergence.
Model tiered latency
Use edge-hit, shield-hit and origin probabilities. Calculate expected latency, then vary origin latency and edge hit rate.
Report a percentile scenario, not only a mean.
Plan a safe invalidation
For a fictional stylesheet update, compare same-URL purge with a versioned filename. List which documents must change and how rollback works.
This transfers to software releases and data migrations.
Guidance for Parents and Teachers
Start with library copies
A popular book can be held in neighbourhood branches. A nearby copy is quick; a missing copy comes from the central store. Old editions need replacement or clear labelling.
Then show where the analogy breaks: digital copies have keys, timed directives and automated routing.
Ask for the denominator
Whenever a student reports “95% cached,” ask whether that means requests, bytes, objects or avoided origin work.
Precision in ratios is a core mathematical habit.
Include responsibility
Serving old emergency, price or account data can harm people. Students should classify content by freshness and privacy risk before optimising speed.
Fast is not the only objective.
Mathematics Learning in Singapore
The MOE secondary mathematics syllabuses emphasise problem solving with ratio, functions, probability, statistics and graphs. CDNs connect these ideas: hit ratios compare parts to wholes, weighted expectations model latency, expiry is a time inequality, and popularity distributions guide storage.
Students can learn through simulations without touching a production CDN. The transferable skill is to define keys, costs, lifetimes, distributions and safety constraints.
SEAB states that the Singapore-Cambridge Secondary Education Certificate begins in 2027 with G1, G2 and G3 subjects; see the SEC page. This is enrichment, not an examination claim.
Did You Know?
A CDN with a 99.9% offload ratio can still send thousands of requests per second to origin when total demand is enormous.
Changing an asset's filename to include a content hash can make long-lived caching safer because different bytes receive a different name.
One global purge can produce a larger origin spike than the traffic incident it was meant to fix.
Frequently Asked Questions
What mathematics is most useful for CDNs?
Start with ratios, weighted averages, time intervals and graphs. Probability, statistics, queueing and optimisation become important at scale.
What is a cache hit?
It is a request served from a reusable cached response under the cache's key and HTTP policy.
Why can two users see different versions?
They may reach different edges with different cache ages, variants, routes or purge completion times.
Does no-cache mean never store?
No. Under HTTP caching rules it requires successful validation before reuse. `no-store` addresses storage.
When is stale content acceptable?
Only when the content owner has defined a bounded policy and the harm of temporary staleness is acceptable.
Should every response be cached?
No. Personalised, sensitive or rapidly changing responses may be unsuitable for shared reuse.
Does CDN knowledge guarantee a cloud career?
No. It supports a pathway with networking, HTTP, security, programming, systems and communication.
Useful Next Reading
- Read IETF RFC 9111 on HTTP Caching.
- Read RFC 5861 for stale-while-revalidate and stale-if-error controls.
- Connect name resolution to DNS resolution, TTLs, caching and latency.
- Compare local reuse with computer memory, cache hits, latency and bandwidth.
- Review the MOE secondary mathematics syllabuses.
Final Perspective
Content delivery networks show why mathematics matters when the same information is requested around the world. Cache keys decide sameness, lifetimes bound reuse, probability predicts hits, and latency paths reveal where speed is gained. Invalidation and stale service make freshness a controlled policy rather than a slogan.
The strongest question is not “Is it behind a CDN?” It is “Which requests share a key, what fraction hits each tier, how old may the response be, what happens on expiry or failure, and how quickly can a change converge?”
Those questions turn edge delivery from invisible acceleration into a reasoned system. They also teach students that speed, correctness, privacy and resilience must be modelled together.