
September 12, 2026
11 min read
By Kokil Thapa | Last reviewed: September 2026
Your origin server in Kathmandu can serve a page in 200 ms locally. A visitor in Doha or Sydney may wait two seconds for the same HTML, CSS, and images. CDN Fundamentals: How Content Delivery Works starts with that gap. A content delivery network copies cacheable assets to edge points of presence (PoPs) worldwide. Users fetch files from the nearest healthy node instead of your single server. On production web applications in Nepal and abroad, that shift often cuts Time to First Byte and improves Core Web Vitals without rewriting application code.
What is a CDN and why does CDN content delivery matter?
A content delivery network is a distributed system of edge servers operated by a provider such as Cloudflare, AWS CloudFront, Fastly, or BunnyCDN. Each PoP sits on high-bandwidth networks close to end users. The provider handles TLS termination, HTTP/2 or HTTP/3, compression, and routing logic at the edge.
The origin remains your VPS, shared host, or cloud instance running Laravel, WordPress, or Magento. The CDN sits in front as a reverse proxy and cache layer. Most traffic for images, CSS, JavaScript, fonts, and PDFs never touches origin after the first fetch.
I've seen this pattern on international eCommerce builds like florist shops serving Gulf and South Asian markets. Product images and theme assets dominate page weight. Serving them from Singapore or Mumbai PoPs beats routing every byte through a single origin in Nepal or Europe.
Benefits extend beyond speed. A CDN absorbs traffic spikes during Dashain sales or a viral blog post. DDoS mitigation and WAF rules often ship with the same provider. For technical SEO, faster LCP and stable TTFB correlate with better crawl efficiency and user retention.
How does CDN content delivery work step by step?
Understanding the request path prevents misconfigured caches and mysterious stale files. Every CDN interaction follows the same logical sequence.
- DNS resolution. Your domain's CNAME or ANAME points
cdn.example.comor the apex domain to the provider. See how DNS works for the full chain from resolver to authoritative nameserver. - Edge routing. Anycast or geo-DNS sends the client to the closest healthy PoP. Latency-based routing picks among several nodes in the same region.
- Cache lookup. The edge checks its local store for the URL key, query string rules, and
Varyheaders. - Cache hit. If a fresh object exists, the edge returns it with low latency. No origin round trip occurs.
- Cache miss. The edge fetches from origin, stores the response per cache rules, then serves the client.
- Revalidation. On stale objects, the edge may send conditional requests with
If-None-MatchorIf-Modified-Since. A 304 response saves bandwidth.
Pull vs push CDNs
Most modern CDNs use a pull model. The edge fetches on first request. You change DNS or CNAME and assets propagate lazily. A push model uploads files to storage the CDN controls. Live streaming and large software downloads sometimes use push. For typical Laravel or WordPress sites, pull is simpler and cheaper.
Anycast and health checks
Providers advertise the same IP block from many locations. BGP routes packets to the nearest PoP. Health probes remove failed nodes from rotation. If Mumbai goes dark, traffic shifts to Singapore without DNS changes.
What content belongs on a CDN versus the origin?
Not every byte should be cached at the edge. Match asset type to TTL and cache key rules.
| Asset type | CDN fit | Typical TTL | Notes |
|---|---|---|---|
| Images, CSS, JS, fonts | Excellent | 7–365 days | Use fingerprinted filenames from Vite or Mix |
| Public PDFs, videos | Excellent | 1–30 days | Large files benefit most from edge bandwidth |
| HTML pages (marketing) | Good with care | Minutes to hours | Respect cookies and Cache-Control: private |
| Authenticated dashboards | Poor | Do not cache | Bypass cache for session cookies |
| API JSON responses | Case by case | 0–60 seconds | Only idempotent GET with explicit headers |
| Cart, checkout, webhooks | Never | 0 | Always origin-direct |
On a legal-tech portal I built, public guide pages cache well. Client document areas must never hit shared edge cache. Cookie-based cache bypass rules are non-negotiable there.
WooCommerce and custom Laravel carts need the same split. Static product media on the CDN; checkout and account routes excluded via page rules or cache keys. Our eCommerce development practice treats that boundary as a launch checklist item.
How do you set cache headers and CDN rules correctly?
The CDN honours HTTP caching semantics defined in MDN's HTTP caching guide and RFC 9111. Your origin must send intentional headers. Defaults from Apache or nginx often cache too much or too little.
Essential response headers
Cache-Control: public, max-age=31536000, immutablefor versioned assets.Cache-Control: public, max-age=3600, s-maxage=86400for HTML where the CDN may hold longer than browsers.Cache-Control: private, no-storefor authenticated responses.ETagandLast-Modifiedfor efficient revalidation.Vary: Accept-Encodingwhen gzip and Brotli variants exist.
Apache example for static assets
<FilesMatch "\.(css|js|jpg|jpeg|png|webp|woff2)$">
Header set Cache-Control "public, max-age=31536000, immutable"
</FilesMatch>
<FilesMatch "\.(html|php)$">
Header set Cache-Control "public, max-age=0, must-revalidate"
</FilesMatch> Laravel middleware for API fragments
public function handle(Request $request, Closure $next)
{
$response = $next($request);
if ($request->isMethod('GET') && $response->isSuccessful()) {
$response->headers->set(
'Cache-Control',
'public, max-age=60, s-maxage=300'
);
}
return $response;
} Laravel 13 on PHP 8.3+ pairs well with Vite 8.x fingerprinted builds. Filenames like app-B2k9f.js allow aggressive immutable caching. Details for CloudFront and Laravel appear in our AWS CloudFront CDN setup guide. Cloudflare-specific page rules are covered in the Cloudflare CDN setup article.
Purge and invalidation
When you deploy without fingerprinted assets, you must purge CDN cache. Methods include API purge by URL, tag, or prefix. On Deployer releases I purge /build/* after symlink swap. Forgetting purge after a hotfix is a common source of "I deployed but users still see the old JS."
Which CDN setup fits Nepal-based and global projects in 2026?
Provider choice depends on traffic geography, budget, and stack. Nepal-origin sites often mix local hosting with a global CDN front door.
| Provider | Strengths | Typical cost | Good for |
|---|---|---|---|
| Cloudflare (free/pro) | DNS, WAF, DDoS, easy SSL | Rs 0–2,500/mo (~USD 0–19) | WordPress, SMB, legal portals |
| AWS CloudFront | S3 origin, Lambda@Edge | Pay per GB egress | Laravel on EC2, API-heavy apps |
| BunnyCDN | Low cost, simple pull zones | Rs 800+/mo (~USD 6+) | Media-heavy eCommerce |
| Fastly | Instant purge, edge compute | Higher, enterprise | News, high-churn content |
For many Nepal SMB sites, Cloudflare's free tier plus Let's Encrypt on origin covers 80% of needs. That aligns with advice in why Nepali businesses should use a CDN. Enterprise Laravel apps on AWS often standardise on CloudFront with an S3 bucket for compiled assets.
Domain and hosting setup should plan CDN DNS before go-live. Moving apex domains later adds downtime risk. I register the domain, point nameservers to the CDN when applicable, and keep origin IP restricted to provider IP ranges where possible.
What production mistakes break CDN caching?
These issues appear repeatedly on client audits and post-launch support calls.
- Query string cache busting without CDN rule.
style.css?v=2creates a new cache key. Configure the CDN to ignore benign query params or use filename hashing instead. - Setting cookies on static assets. Some analytics scripts set cookies on every path.
Set-Cookieon CSS breaks cache at many providers. - HTTPS mixed content. Page loads over CDN SSL but assets call
http://origin URLs. Browsers block or bypass cache. - Over-aggressive HTML caching. Logged-in users see another user's cached page. Use
Cache-Control: privateor bypass rules for cookies likewordpress_logged_in. - Forgetting origin firewall. Origin exposed to the open internet receives direct traffic and attacks. Allow only CDN egress IPs.
- Stale opcache after deploy without purge. PHP opcache and CDN edge cache are separate layers. Reload PHP-FPM and purge CDN after releases.
Our testing and optimization service includes cache verification with curl -I from multiple regions. A single browser test from your desk hides edge behaviour.
curl -sI https://cdn.example.com/build/app.css | grep -i cache-control
curl -sI https://cdn.example.com/build/app.css | grep -i x-cache The X-Cache: HIT or CF-Cache-Status: HIT response header confirms edge delivery. Miss headers after repeated requests point to misconfigured TTL or bypass rules.
Redis 8.10 at origin handles application cache separately from CDN edge cache. Do not conflate them. Laravel php artisan config:cache affects server-side config. CDN purge does not flush Redis sessions or query cache.
For performance budgets, pair CDN work with image compression and lazy loading. A fast edge cannot fix unoptimised 2 MB hero images. Speed optimization treats CDN as one layer in a full stack review.
On travel booking sites, itinerary PDFs and gallery images moved to a pull zone cut origin egress bills noticeably. The booking engine itself stayed origin-direct with no cache. That split is the pattern to copy.
Security headers like Strict-Transport-Security and Content-Security-Policy should be set at origin or edge consistently. Cloudflare and CloudFront both support transform rules. Document your chosen layer so the next developer does not duplicate or conflict headers.
If you serve Nepali Unicode content, encoding must stay UTF-8 end to end. A mismatched charset header causes garbled text that caching preserves for hours. Our Nepali Unicode converter helps validate text before publish, but the CDN will faithfully cache whatever origin returns.
Official provider docs remain the source of truth for limits and API quotas. See Cloudflare Cache documentation and Amazon CloudFront Developer Guide for purge APIs, tiered cache, and origin shield options.
Key Takeaways
- A CDN caches assets at edge PoPs so users fetch content geographically close to them instead of always hitting your origin.
- Cache hits return in tens of milliseconds; misses fetch origin once then warm the edge for subsequent requests.
- Put images, CSS, JS, fonts, and public downloads on the CDN; keep checkout, admin, and authenticated routes uncached.
- Send explicit
Cache-Controlheaders and use fingerprinted asset names from Vite or Mix for long TTLs. - Purge CDN cache after deploys that change non-fingerprinted files, and restrict origin access to provider IP ranges.
- Match provider to stack: Cloudflare for SMB WordPress, CloudFront for AWS Laravel, BunnyCDN for media-heavy shops.
People Also Ask
Is a CDN the same as web hosting?
No. Hosting runs your application and database on an origin server. A CDN caches and delivers copies of static and cacheable responses from edge nodes. You still need hosting; the CDN sits in front as a performance and protection layer.
Does a CDN help SEO?
Yes, indirectly. Faster LCP, INP, and TTFB improve user experience signals and crawl budget efficiency. Google does not rank "CDN use" as a factor, but speed and availability affect outcomes. Pair CDN with sound content freshness strategy.
Can you use a CDN with a shared hosting plan?
Yes. Point your domain DNS to Cloudflare or similar and set the shared host as origin. Most pull CDNs work without root server access. You configure cache headers via .htaccess on Apache hosts common in Nepal.
What is origin shield?
Origin shield is an intermediate cache tier between regional PoPs and your server. Multiple edge misses collapse into one origin fetch. AWS CloudFront and some enterprise tiers offer it. It helps high-traffic sites reduce origin load during viral spikes.
Ship faster pages with CDN fundamentals applied correctly
CDN Fundamentals: How Content Delivery Works boils down to one idea: move bytes closer to users and cache aggressively where safe. DNS to edge, edge to origin on miss, purge on deploy, and never cache private sessions. On real projects—from legal information portals to cross-border eCommerce—that discipline delivers measurable speed without rewriting business logic.
If you want CDN wired into your Laravel, WordPress, or WooCommerce stack with correct headers, firewall rules, and deploy purge automation, review our support and maintenance offerings or browse the full project portfolio. Need hands-on help? Contact us to audit origin and edge configuration before your next launch.
Frequently Asked Questions
0 Comments
Leave a comment
Your email is not published. Comments appear once they have been read. Sign in to have your details filled in.

