Breaking down what makes a conditional GET:
In RFC 2616 it states that the GET method change to a "conditional GET" if the request message includes an If-*
(If-Modified-Since
, If-Unmodified-Since
, If-Match
, If-None-Match
, or If-Range
) header field.
It then states:
A conditional GET method requests that the entity be transferred ONLY under the circumstances described by the conditional header field(s).
From my understanding this is saying it will only return the data being requested if the condition is met with the "If-*
" in any new subsequent requests. For example, if a GET request returns a response with a Etag
header then the next request must include the If-None-Match
with the ETag
value to transfer the client back the requested resource.
However, If a client has to send an initial request before getting the returned "ETag
" header (to return with If-None-Match
) then they already have the requested resource. Thus, any future requests that return the If-None-Match
header with the ETag
value only dictate the return of the requested value, returning 200 OK (if the client does not return the If-None-Match
and ETag
value from initial request) or 304 Not Modified (if they do), where this helps the client and server by caching the resource.
My Question:
Why does it state the entity (the resource from a request) will "be transferred ONLY" if the If-*
condition is met (like in my example where the client returns the ETag
value with anIf-None-Match
in order to cache the requested resource) if the resource or "entity" is being returned with or without a "If-*
" being returned? It doesn't return a resource "only under the circumstances described by the conditional header" because it returns the resource despiteless returning 200 OK or 304 Not Modified depending on if a "If-*
" header is returned. What am I misunderstanding about this?
Full conditional GET reference from RFC 2616:
The semantics of the GET method change to a "conditional GET" if the request message includes an If-Modified-Since, If-Unmodified-Since, If-Match, If-None-Match, or If-Range header field. A conditional GET method requests that the entity be transferred only under the circumstances described by the conditional header field(s). The conditional GET method is intended to reduce unnecessary network usage by allowing cached entities to be refreshed without requiring multiple requests or transferring data already held by the client.