0
0
Rest APIprogramming~5 mins

ETag for conditional requests in Rest API - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is an ETag in the context of REST APIs?
An ETag (Entity Tag) is a unique identifier assigned by a server to a specific version of a resource. It helps clients know if the resource has changed since the last time they accessed it.
Click to reveal answer
beginner
How does a client use an ETag for conditional requests?
The client sends the ETag value in the 'If-None-Match' header when requesting a resource. The server compares it with the current ETag and returns the resource only if it has changed; otherwise, it returns a 304 Not Modified status.
Click to reveal answer
beginner
What HTTP status code indicates that the resource has not changed when using ETag?
The server returns HTTP status code 304 Not Modified to tell the client that the resource has not changed and the cached version can be used.
Click to reveal answer
intermediate
Why are ETags useful for web performance?
ETags reduce bandwidth and improve performance by allowing clients to avoid downloading unchanged resources. This saves time and network data by using cached versions when possible.
Click to reveal answer
intermediate
What is the difference between a strong and a weak ETag?
A strong ETag changes whenever the resource changes in any way. A weak ETag may not change for minor differences and is prefixed with 'W/'. Weak ETags allow some flexibility in caching but may not detect all changes.
Click to reveal answer
What header does a client send to use an ETag for conditional GET requests?
AIf-None-Match
BIf-Match
CETag
DCache-Control
What does the server return if the resource has not changed when using ETag?
A304 Not Modified
B404 Not Found
C200 OK with resource
D500 Internal Server Error
Which of the following best describes a weak ETag?
AAn ETag that is always a hash of the resource content
BAn ETag that changes with every minor change
CAn ETag used only for POST requests
DAn ETag prefixed with 'W/' that may not change for minor differences
Why are ETags important for caching?
AThey force the client to always download the resource
BThey help the client know if the cached resource is still valid
CThey encrypt the resource data
DThey replace the URL of the resource
Which HTTP method commonly uses ETags for conditional requests?
APUT
BDELETE
CGET
DOPTIONS
Explain how ETags help improve web application performance.
Think about how caching works with version checks.
You got /5 concepts.
    Describe the difference between strong and weak ETags and when you might use each.
    Consider strictness of change detection.
    You got /5 concepts.