HTTP caching and content delivery
You measure how browser, proxy and CDN caches work through headers and diagnose stale content and cache misses.
Level 301 · 17 lessons · 15 practice labs
Lessons
Caching rules
- Why and where to cache: from the browser to the CDN
- Cache-Control directives: max-age, no-store, private
- Freshness calculation and the Age header
- Validation: ETag, Last-Modified and 304
- The Vary header and the cache key
- Short task: map a site’s caching policy
Proxies and CDNs
- Caching in a reverse proxy: Nginx proxy_cache
- Reading cache status headers: HIT, MISS, STALE
- stale-while-revalidate and stale-if-error
- How a CDN works: edge servers and the origin
- Purging caches and versioned file names
- Short task: find why a page doesn’t update
Caching safely
- Keeping personal data out of shared caches
- How cookies and caches interact
- A first look at the Service Worker cache
- Measuring the cache hit ratio from logs
- Capstone: build and measure a caching plan for a site
Practice labs
- Read the cache headers: Tabulate the Cache-Control, Expires and Age headers of five resources and note how long each stays fresh.
- Pick the right Cache-Control rule: Choose fitting directives for a logo, a price list and an account page and apply them in Nginx.
- Map a caching policy: Group every resource type on Kestane News and report where and how long each group is cached.
- See a 304 response: Send an If-None-Match request with the ETag and show the server answers 304 without a body.
- Set up validation with Last-Modified: Enable Last-Modified and If-Modified-Since on a dynamic report and measure the traffic saved.
- Separate versions mixed up by Vary: Mobile and desktop users see each other's pages; fix the cache key and the Vary header.
- Turn on the Nginx cache: Add proxy_cache in front of the product API and show HIT and MISS with an X-Cache-Status header.
- Serve stale content when the back end fails: Set stale-if-error and proxy_cache_use_stale and prove the site stays up when the back end is stopped.
- Compute the hit ratio from logs: Log the cache status, compute the hit ratio over an hour of traffic and find the URLs pulling it down.
- Find why a page doesn't update: New prices don't show on the site; use response headers to find which layer holds the old version.
- Switch to versioned file names: Add content hashes to style and script names with long-lived caching and verify the HTML always stays fresh.
- Purge an edge cache: One of two lab edge servers still holds old content; send a purge and verify both edges.
- Stop a personal page being cached: Add private and no-store to the account summary and show the shared cache no longer keeps it.
- Find a leak in a cookie response: One user's name shows to another; find how a response carrying Set-Cookie entered the cache and close it.
- Inspect a Service Worker cache: In an app showing an old version, list the files in the Service Worker cache and fix its update strategy.
About this course
You measure how browser, proxy and CDN caches work through headers and diagnose stale content and cache misses.
What you will learn
- Caching rules
- Proxies and CDNs
- Caching safely
Prerequisites
You should be comfortable with the level 101 and 201 topics of the same path.
Lab environment
Lessons run in your own Kali Linux terminal in the browser, connected to a private lab network. Nothing to install.
Frequently asked questions
- Is this course right for my level?
- The course is at level 301; it assumes you know the topics of the lower-level courses.
- Is there anything to install?
- No. Every lesson runs in your own lab environment that opens in the browser.
- How do lessons work?
- Each lesson has 8 to 10 steps and a short quiz. Early steps show the command to type, later steps give less help; if two attempts fail, the solution opens.
- Can I try it for free?
- Yes. The first three lessons of every course are free.