0
0
Rest APIprogramming~5 mins

Response headers (Cache-Control, ETag) in Rest API - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is the purpose of the Cache-Control header in HTTP responses?
The Cache-Control header tells browsers and other clients how to store and reuse the response. It controls caching behavior like how long to keep the data or whether to cache it at all.
Click to reveal answer
beginner
Explain what an ETag header does in HTTP responses.
An ETag is a unique identifier for a specific version of a resource. It helps clients check if the resource has changed since the last request, enabling efficient caching and conditional requests.
Click to reveal answer
intermediate
What does the directive Cache-Control: no-cache mean?
It means the client must revalidate with the server before using a cached copy. The cached response can be stored but must be checked for freshness before reuse.
Click to reveal answer
intermediate
How does the client use the If-None-Match header with ETag?
The client sends If-None-Match with the ETag value it has. The server compares it to the current ETag. If they match, the server replies with 304 Not Modified, saving bandwidth.
Click to reveal answer
beginner
Why are Cache-Control and ETag headers important for REST APIs?
They improve performance by reducing unnecessary data transfer and server load. Cache-Control manages how responses are cached, and ETag helps detect changes to resources efficiently.
Click to reveal answer
What does the Cache-Control: max-age=3600 header instruct the client to do?
AImmediately revalidate the response
BNever cache the response
CCache the response forever
DCache the response for 3600 seconds before revalidating
Which header is used by the client to tell the server the version of the resource it has cached?
ACache-Control
BIf-None-Match
CETag
DLast-Modified
What response status code does the server send if the resource has not changed when using ETag validation?
A200 OK
B404 Not Found
C304 Not Modified
D500 Internal Server Error
If a response has Cache-Control: no-store, what does it mean?
AThe response must not be cached anywhere
BThe response can be cached indefinitely
CThe response can be cached but must be revalidated
DThe response is private
Which header helps reduce bandwidth by avoiding sending unchanged resources?
AETag
BCache-Control
CContent-Type
DAuthorization
Describe how Cache-Control and ETag headers work together to improve API performance.
Think about caching rules and how the client checks if data changed.
You got /5 concepts.
    Explain the difference between Cache-Control: no-cache and Cache-Control: no-store.
    Focus on whether caching is allowed or not.
    You got /4 concepts.