Caching & CDN Questions with Answers

13 practice questions on Caching & CDN (Modern Web (Next.js, PWA, Performance)) with answers and step-by-step solutions. Try 10 samples below, then practise all 13 free in the AptiNest app.

Sample questions

Question 1Easy

What does Cache-Control: max-age=3600 tell a cache?

  1. The response is fresh for 3600 seconds
  2. The response must be refetched after 3600 requests
  3. The response may be stored for up to 3600 KB
  4. The response expires 3600 minutes after midnight

Answer: A. The response is fresh for 3600 seconds

Explanation

max-age is a freshness lifetime in seconds.

Step-by-step solution

  1. Max-age sets a freshness lifetime in seconds.
  2. The value 3600 means one hour.
  3. During that time a cache may use the copy without asking the server.
  4. So the correct answer is the response is fresh for 3600 seconds.

Why the other options are wrong

  • B. Max-age counts seconds, not requests.
  • C. Max-age is a time, not a size limit.
  • D. Max-age is counted from the response time, not from midnight.

Tip: Max-age is always seconds: 3600 is one hour, 31536000 is one year.

Question 2Easy

What does Cache-Control: no-cache actually mean?

  1. Only the CDN may cache it, never the browser
  2. It may be stored but must be revalidated
  3. The response is cached forever without checks
  4. The response must never be stored anywhere

Answer: B. It may be stored but must be revalidated

Explanation

Despite the name, no-cache allows storage but requires revalidation with the origin each time; no-store is the one that forbids storage.

Step-by-step solution

  1. No-cache allows a cache to store the response.
  2. But before each use, the cache must revalidate with the origin.
  3. The name is misleading: it does not mean no caching.
  4. So the correct answer is it may be stored but must be revalidated.

Why the other options are wrong

  • A. No-cache is not limited to the CDN; browsers can store it too.
  • C. No checks means the response is cached forever; no-cache always checks.
  • D. A response that must never be stored is no-store.

Tip: No-cache = store and check every time; no-store = never store.

Question 3Easy

What is the main job of a content delivery network (CDN) for a website?

  1. Replaces the need for an origin server entirely
  2. Stores user passwords securely for the app
  3. Serves content from servers close to users
  4. Compiles front-end code during deployment

Answer: C. Serves content from servers close to users

Explanation

A content delivery network caches content on edge servers around the world, lowering latency and origin load.

Step-by-step solution

  1. A CDN is a network of edge servers spread around the world.
  2. It caches content on servers close to the user.
  3. This lowers latency and reduces load on the origin.
  4. So the correct answer is serving content from servers close to users.

Why the other options are wrong

  • A. A CDN still relies on an origin server for content it does not have.
  • B. Passwords are not a CDN's job; they belong in the app backend.
  • D. Compiling front-end code happens in the build step, not in a CDN.

Tip: CDN = cache near the user; origin server stays the source of truth.

Question 4Easy

What does Cache-Control: no-store mean?

  1. Store it but always revalidate before use
  2. Store it for one hour and then delete it
  3. Store it only in the browser cache
  4. Do not store the response in any cache

Answer: D. Do not store the response in any cache

Explanation

no-store forbids caching entirely; it suits sensitive responses.

Step-by-step solution

  1. Cache-Control sets rules for storing responses.
  2. No-store tells every cache not to keep the response.
  3. Use it for sensitive responses such as banking pages.
  4. So the correct answer is do not store the response in any cache.

Why the other options are wrong

  • A. Store and revalidate is no-cache, not no-store.
  • B. Deleting after an hour is not a meaning of no-store.
  • C. Browser-only storage is private, not no-store.

Tip: No-store = never store; no-cache = store but always revalidate.

Question 5Medium

What does s-maxage in Cache-Control control?

  1. The number of seconds before a session ends
  2. Freshness lifetime in CDNs and proxies
  3. The maximum size of the cached response
  4. Freshness lifetime in the browser only

Answer: B. Freshness lifetime in CDNs and proxies

Explanation

s-maxage applies to shared caches (proxies, CDNs) and overrides max-age there.

Step-by-step solution

  1. Cache-Control max-age applies to all caches.
  2. s-maxage applies only to shared caches such as proxies and CDNs.
  3. When present, it overrides max-age for those shared caches.
  4. So the correct answer is the freshness lifetime in CDNs and proxies.

Why the other options are wrong

  • A. Session length is not controlled by Cache-Control.
  • C. The cache size of a response is not set by s-maxage.
  • D. The browser ignores s-maxage; it is for shared caches.

Tip: s- prefix in Cache-Control means shared caches only (CDNs, proxies).

Question 6Medium

Why do build tools add a content hash to filenames such as app.3f9a2c.js?

  1. So it can be cached long-term; new content gets a new URL
  2. So that each user downloads a unique copy of the file
  3. So that the browser can verify the file was not tampered with
  4. So that the CDN can compress the file more effectively

Answer: A. So it can be cached long-term; new content gets a new URL

Explanation

A changed file gets a new URL, so it can safely be served with a long max-age and immutable without stale-cache issues.

Step-by-step solution

  1. A content hash changes whenever the file content changes.
  2. A changed file therefore gets a new URL.
  3. Old URLs can stay cached for a long time without serving stale code.
  4. So the correct answer is long-term caching, since new content gets a new URL.

Why the other options are wrong

  • B. Users all receive the same file; the hash is not per user.
  • C. A content hash is not a security signature and does not verify tampering.
  • D. The hash does not change compression; it changes the URL.

Tip: Hashed filenames let you use max-age=31536000, immutable safely.

Question 7Medium

What does Cache-Control: private mean?

  1. The response can be cached by CDNs only
  2. The response is never cached by anything
  3. Only the browser may cache it, not CDNs
  4. The response is encrypted and needs a key

Answer: C. Only the browser may cache it, not CDNs

Explanation

private responses (e.g. user-specific pages) may be stored by the browser but not by CDNs or proxies.

Step-by-step solution

  1. Private means the response is for a single user.
  2. The browser may store it.
  3. Shared caches such as CDNs and proxies must not store it.
  4. So the correct answer is only the browser may cache it, not CDNs.

Why the other options are wrong

  • A. It is the opposite: CDNs are the ones excluded.
  • B. Private still allows browser caching, so it is not never cached.
  • D. Private is about who may cache, not about encryption.

Tip: private = browser only; public = any cache; use private for user-specific pages.

Question 8Medium

What HTTP status does a server return when a conditional request finds the resource unchanged?

  1. 204 No Content
  2. 302 Found (redirect to cache)
  3. 200 OK
  4. 304 Not Modified

Answer: D. 304 Not Modified

Explanation

304 tells the client to use its cached copy; no body is sent.

Step-by-step solution

  1. A conditional request sends If-None-Match or If-Modified-Since.
  2. If the resource has not changed, the server responds without a body.
  3. The status for that is 304 Not Modified.
  4. So the correct answer is 304 Not Modified.

Why the other options are wrong

  • A. 204 means success with no body, but not for an unchanged cached resource.
  • B. 302 is a redirect, not a cache check result.
  • C. 200 sends the full resource body, which is not used when unchanged.

Tip: 304 Not Modified = use your cached copy; no body is sent.

Question 9Hard

Which header combination is typical for a hashed static asset like /assets/app.3f9a2c.js?

  1. Cache-Control: no-cache, private
  2. Cache-Control: no-store
  3. Cache-Control: public, max-age=31536000, immutable
  4. Cache-Control: max-age=0, must-revalidate, private

Answer: C. Cache-Control: public, max-age=31536000, immutable

Explanation

The filename changes whenever content changes, so the URL can be cached for a year and marked immutable to skip revalidation.

Step-by-step solution

  1. The hashed filename changes when content changes.
  2. So the URL can be cached for a year.
  3. Immutable tells the browser not to revalidate during that time.
  4. So the correct answer is public, max-age=31536000, immutable.

Why the other options are wrong

  • A. No-cache forces revalidation, which wastes the benefit of hashed names.
  • B. No-store stops all caching of the file.
  • D. Max-age=0 with must-revalidate forces a check on every use.

Tip: Hashed static assets: public, max-age=31536000, immutable.

Question 10Hard

A site serves index.html with Cache-Control: max-age=31536000 and deploys new hashed JS files. What problem appears?

  1. Users download the new JS but with the old CSS
  2. Users keep old HTML pointing at old JS
  3. Nothing; long max-age on HTML is best practice
  4. The CDN refuses to serve files with long max-age

Answer: B. Users keep old HTML pointing at old JS

Explanation

The HTML is the entry point that references hashed assets; caching it for a year means users never see new deployments. HTML is usually no-cache or short-lived.

Step-by-step solution

  1. index.html is the entry point that names the hashed JS files.
  2. With max-age one year, browsers keep the old index.html.
  3. The old HTML points at old JS files, so users miss the new deployment.
  4. So the correct answer is users keeping old HTML that points at old JS.

Why the other options are wrong

  • A. The HTML decides which JS and CSS load, so the mismatch is not about old CSS alone.
  • C. A long max-age on HTML is not best practice; HTML should be no-cache or short-lived.
  • D. CDNs do not refuse long max-age.

Tip: Hashed assets can be cached for a year, but the HTML entry point should be no-cache or short-lived.

Practise all 13 questions free

The full question bank with timed practice, progress tracking and Vidya, your AI tutor. Free, no ads.

Open this topic in the app →

Related topics

See all Modern Web (Next.js, PWA, Performance) topics · All topics