0
0
Expressframework~5 mins

Conditional requests handling in Express - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is the purpose of conditional requests in Express?
Conditional requests help the server decide if it needs to send the full response or just a status like 304 Not Modified, saving bandwidth and improving speed.
Click to reveal answer
beginner
Which HTTP headers are commonly used for conditional requests?
The main headers are If-None-Match (for ETag) and If-Modified-Since (for last modified date). They tell the server what version the client has.
Click to reveal answer
intermediate
How does Express help handle conditional GET requests?
Express provides the res.sendFile() and res.send() methods that automatically check request headers and send a 304 status if the resource is unchanged.
Click to reveal answer
intermediate
What is an ETag and how is it used in Express conditional requests?
An ETag is a unique identifier for a resource version. Express can set ETags automatically, and clients send them back in If-None-Match headers to check if the resource changed.
Click to reveal answer
advanced
How can you manually handle conditional requests in Express?
You can check request headers like req.headers['if-none-match'] or req.headers['if-modified-since'], compare with your resource state, and respond with res.status(304).end() if unchanged.
Click to reveal answer
Which status code indicates the resource has NOT changed in a conditional request?
A200 OK
B500 Internal Server Error
C404 Not Found
D304 Not Modified
Which header does the client send to check if the resource's ETag matches?
AIf-None-Match
BIf-Modified-Since
CETag
DContent-Type
What does Express do when you use res.sendFile() with conditional headers?
AAlways sends full file content
BAutomatically sends 304 if resource is unchanged
CIgnores conditional headers
DThrows an error
Which header is used to check if a resource has been modified since a certain date?
ALast-Modified
BIf-None-Match
CIf-Modified-Since
DContent-Length
How can you respond with 304 Not Modified manually in Express?
Ares.status(304).end()
Bres.send(304)
Cres.json(304)
Dres.redirect(304)
Explain how Express handles conditional GET requests using ETag and If-None-Match headers.
Think about how the server knows if the client has the latest version.
You got /5 concepts.
    Describe how you would manually implement conditional request handling in an Express route.
    Focus on checking headers and deciding the response status.
    You got /4 concepts.