0
0
Expressframework~5 mins

HTTP caching headers (ETag, Cache-Control) in Express - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
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?
AThe size of the resource in bytes
BA unique version identifier for a resource
CThe expiration time of a cached resource
DThe server's IP address
Which Cache-Control directive tells the browser to always fetch a fresh copy?
Ano-cache
Bmax-age=3600
Cpublic
Dprivate
In Express, how can you disable automatic ETag generation?
Aapp.etag = false
Bapp.disable('etag')
Capp.use(etag(false))
Dapp.set('etag', false)
What does Cache-Control: max-age=0 mean?
ACache forever
BDo not cache at all
CResource is stale immediately and must be revalidated
DCache for 1 hour
Which header does the browser send to check if the cached resource matches the server's version?
AIf-None-Match
BETag
CCache-Control
DIf-Modified-Since
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.