Recall & Review
beginner
What is the purpose of the
ETag HTTP header?The
ETag header provides a unique identifier for a specific version of a resource. It helps browsers and servers check if the resource has changed, so the browser can use a cached version if it hasn't.Click to reveal answer
beginner
Explain the role of the
Cache-Control header in HTTP caching.The
Cache-Control header tells browsers and proxies how to store and reuse responses. It can specify how long to keep a resource, whether to revalidate it, or if it should not be cached at all.Click to reveal answer
intermediate
How does Express help you set
ETag headers automatically?Express automatically generates
ETag headers for responses by default, based on the response body. This helps with efficient caching without extra code.Click to reveal answer
beginner
What does the
Cache-Control: no-store directive do?It tells browsers and proxies not to store any part of the response. This means the resource will always be fetched fresh from the server.
Click to reveal answer
beginner
Why is it important to use caching headers like
ETag and Cache-Control in web applications?Using caching headers improves performance by reducing unnecessary data transfer. It saves bandwidth, speeds up page loads, and reduces server load by letting browsers reuse cached resources when possible.
Click to reveal answer
What does the
ETag header represent?✗ Incorrect
ETag is a unique identifier for a resource version, used to check if the cached copy is still valid.Which
Cache-Control directive tells the browser to always fetch a fresh copy?✗ Incorrect
no-cache means the browser must revalidate with the server before using the cached resource.In Express, how can you disable automatic
ETag generation?✗ Incorrect
Use
app.set('etag', false) to turn off automatic ETag generation in Express.What does
Cache-Control: max-age=0 mean?✗ Incorrect
max-age=0 means the cached resource is immediately stale and requires revalidation.Which header does the browser send to check if the cached resource matches the server's version?
✗ Incorrect
The browser sends
If-None-Match with the ETag value to ask if the resource has changed.Describe how
ETag and Cache-Control headers work together to improve web performance.Think about how the browser knows when to reuse cached data or ask the server for updates.
You got /4 concepts.
Explain how to set caching headers in an Express app to cache a response for 1 hour.
Remember Cache-Control max-age is in seconds.
You got /3 concepts.