Bird
Raised Fist0
HLDsystem_design~20 mins

CDN caching for static content in HLD - Practice Problems & Coding Challenges

Choose your learning style10 modes available
Challenge - 5 Problems
🎖️
CDN Caching Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
How does a CDN improve performance for static content?

Imagine you have a website serving images and CSS files globally. How does using a CDN help improve the loading speed for users?

ABy requiring users to download all content from the origin server directly.
BBy compressing files on the origin server before sending to users.
CBy dynamically generating static content on each user request.
DBy storing copies of static files closer to users in multiple locations worldwide.
Attempts:
2 left
💡 Hint

Think about how distance affects loading times and where files are stored.

❓ Architecture
intermediate
2:00remaining
Which component is responsible for cache invalidation in a CDN setup?

In a CDN architecture for static content, which part typically handles cache invalidation when content updates?

ACDN edge servers automatically detect changes without any signals.
BThe origin server sends cache purge requests to CDN edge servers.
CUsers manually clear their browser cache to update content.
DDNS servers update cache entries for static files.
Attempts:
2 left
💡 Hint

Consider who controls the original content and how updates propagate.

❓ scaling
advanced
2:00remaining
What is the main benefit of using a CDN for scaling static content delivery during traffic spikes?

Your website experiences sudden high traffic. How does a CDN help handle this increased load for static files?

ABy increasing the origin server's CPU and memory automatically.
BBy storing static content only on the origin server to avoid duplication.
CBy distributing requests across many edge servers, reducing load on the origin server.
DBy blocking excess user requests to limit traffic.
Attempts:
2 left
💡 Hint

Think about how spreading work helps handle more users.

❓ tradeoff
advanced
2:00remaining
What is a tradeoff when setting a very long cache expiration time for static content in a CDN?

Setting a long cache expiration time improves performance but what is a potential downside?

AUsers may see outdated content if the origin updates but CDN cache is not refreshed.
BThe CDN will consume more bandwidth from the origin server.
CThe origin server will have to handle more requests directly.
DStatic content will load slower for users globally.
Attempts:
2 left
💡 Hint

Think about content freshness versus speed.

❓ estimation
expert
3:00remaining
Estimate the bandwidth savings when using a CDN caching 90% of static content requests for a website serving 1TB/month of static files.

Your website serves 1TB of static files monthly. If the CDN cache hit ratio is 90%, how much bandwidth is saved on the origin server?

A900 GB saved, only 100 GB served by origin.
B100 GB saved, 900 GB served by origin.
C1 TB saved, origin serves 0 GB.
DNo bandwidth saved, origin serves full 1 TB.
Attempts:
2 left
💡 Hint

Calculate based on percentage of requests served by CDN cache.

Practice

(1/5)
1. What is the main purpose of using a CDN cache for static content?
easy
A. To delete static files after use
B. To store static files closer to users for faster access
C. To encrypt all static content
D. To increase the size of static files

Solution

  1. Step 1: Understand CDN caching basics

    A CDN cache stores copies of static files like images and scripts near users to reduce loading time.
  2. Step 2: Identify the main benefit

    By storing files closer, users get faster access and the main server has less load.
  3. Final Answer:

    To store static files closer to users for faster access -> Option B
  4. Quick Check:

    CDN caching = faster static content delivery [OK]
Hint: CDN caches static files near users to speed up loading [OK]
Common Mistakes:
  • Thinking CDN increases file size
  • Confusing caching with encryption
  • Assuming CDN deletes files after use
2. Which HTTP header is commonly used to control CDN caching behavior for static content?
easy
A. Cache-Control
B. Content-Type
C. Authorization
D. User-Agent

Solution

  1. Step 1: Identify headers related to caching

    Cache-Control header tells browsers and CDNs how long to keep cached content.
  2. Step 2: Exclude unrelated headers

    Content-Type defines file type, Authorization is for access, User-Agent identifies client.
  3. Final Answer:

    Cache-Control -> Option A
  4. Quick Check:

    Cache-Control header manages caching [OK]
Hint: Cache-Control header sets caching rules for CDNs [OK]
Common Mistakes:
  • Confusing Content-Type with caching
  • Using Authorization header for caching
  • Thinking User-Agent controls cache
3. Given the following Cache-Control header: Cache-Control: max-age=3600, public, what does it mean for CDN caching?
medium
A. Cache content publicly for 3600 seconds
B. Do not cache content at all
C. Cache content privately for 3600 seconds
D. Cache content indefinitely

Solution

  1. Step 1: Interpret max-age directive

    max-age=3600 means cache content for 3600 seconds (1 hour).
  2. Step 2: Understand public directive

    public means content can be cached by any cache, including CDNs and browsers.
  3. Final Answer:

    Cache content publicly for 3600 seconds -> Option A
  4. Quick Check:

    max-age=3600 + public = public cache for 1 hour [OK]
Hint: max-age sets cache time; public allows shared caching [OK]
Common Mistakes:
  • Confusing public with private caching
  • Assuming max-age disables caching
  • Thinking max-age means indefinite caching
4. A CDN is serving outdated static content even after you updated the files on your origin server. What is the most likely cause?
medium
A. The origin server is down
B. The user's browser cache is disabled
C. The static files were deleted from the origin
D. The CDN cache was not invalidated or purged

Solution

  1. Step 1: Understand CDN cache behavior

    CDNs keep cached copies until they expire or are explicitly purged.
  2. Step 2: Identify cause of stale content

    If files updated on origin but CDN still serves old files, cache invalidation likely missing.
  3. Final Answer:

    The CDN cache was not invalidated or purged -> Option D
  4. Quick Check:

    Stale CDN content = missing cache purge [OK]
Hint: Stale CDN content? Check cache invalidation first [OK]
Common Mistakes:
  • Assuming origin server down causes stale CDN cache
  • Thinking deleted origin files cause stale CDN content
  • Blaming user browser cache for CDN stale content
5. You want to ensure users always get the latest version of your static files after you update them, but still benefit from CDN caching. Which approach is best?
hard
A. Disable CDN caching and serve files directly from origin
B. Set Cache-Control to no-cache for all static files
C. Use versioned URLs for static files and set long cache expiration
D. Use short cache expiration without versioning

Solution

  1. Step 1: Understand versioned URLs

    Versioned URLs (e.g., style.v2.css) change file names on update, forcing CDN to fetch new files.
  2. Step 2: Combine with long cache expiration

    Long cache expiration lets CDN cache files efficiently without frequent revalidation.
  3. Step 3: Avoid disabling caching or short expiration

    Disabling caching or short expiration hurts performance and increases load.
  4. Final Answer:

    Use versioned URLs for static files and set long cache expiration -> Option C
  5. Quick Check:

    Versioned URLs + long cache = fresh and fast [OK]
Hint: Version URLs + long cache = fresh content with speed [OK]
Common Mistakes:
  • Disabling CDN caching unnecessarily
  • Using no-cache header causing slow loads
  • Relying on short expiration without versioning
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard