Why did ETags set a MUST requirement if you already have a resource?

Why should you set ETags to "MUST requirements level"?

You get the resource until ETags returns ...

I am working on a project where I am a client who sends HTTP requests to a server that returns an HTTP Cache-Control header with ETags to respond to the cache (where in each add request it is compared to an If-None- Header header to determine whether the data is obsolete and if a new request is required). In my current project, the ETags parameter uses a GET conditional architecture with a MUST requirement level, as specified in RFC 2119.

MUST This word or terms "REQUIRED" or "MUST" mean that the definition is an absolute specification requirement. I don’t understand the intention to use a conditional GET with a LONG level of requirements? In my opinion, the MUST requirement is to limit (is this right?) The resources provided to the client who makes the request, however the client (I have in this case) already has resources from the first request. Where can I continue to receive the same resource (or a more recent resource if it is updated) as much as I want with or without the return of the If-None-Match and ETag header fields.

What would be the purpose of setting it to the MUST requirements level in this case, if it does not limit the returned resources, except that it can cache and limit the number of requests to the server (Im asking from the client point of view, yes I know that I can cache it but why is this a MUST requirement)? Is this not used only to limit resources?

Basically, does this not make a requirement a requirement, if I can get resources with or without it? Did I miss something?

My question is not asking what and how Etags, Cache-Control or If-None-Match headers work.

Thanks Hi!

+6
source share
2 answers

Why did ETags set a MUST requirement if you already have a resource?

A client MUST use a conditional GET to reduce data traffic.

In addition to the ability to cache and limit the number of requests to the server

The number of requests remains unchanged, but the total number of data transferred varies.


Using ETags in non-matching GET requests (conditional GET)

  • When you call an API call, the response header includes an ETag with a value that is a hash of the data returned in the API call. You save this ETag value for use in the following query.
  • The next time you call the API, you include the If-None-Match request header with the ETag value saved from the first step.
    • If the data has not changed , the response status code will be 304 – Not Modified and the data will not be returned.
    • If after the last request the data has changed , the data is returned, as usual, using the new ETag. The game starts again: you save the new ETag value and use it for subsequent requests.

Why?

  • The main reason for using conditional GET requests is to reduce data traffic.

Is this not used only to limit resources?

No...

  • You can request an API for multiple resources in a single request.
    • (Well, this also limits resources by storing other requests.)
  • You can prevent a method (for example, PUT) from modifying an existing resource when the client considers that the resource does not exist (replace the protection).

Can I get resources with or without it?

When you ignore “MUST use a conditional GET,” then (a) the traffic will increase, and (b) you will lose the indication “resource changed” coming from the server side. You will need to implement client-side comparison processing: is the second request resource newer than the one from the first request.

+3
source

I found that my question did not ask the “right question” because I changed my understanding of other headers (thanks to @dcerecedo's comment for pointing in the right direction), which influenced my understanding of why MUST was b.

MUST was more susceptible to other headers, in my case private , max-age=3600 and must-revalidate

Where

  • Cache-Control: private limits proxy servers from caching, this helps you store data from a server that you trust, and does not allow the proxy server to cache user data that is not related to everything (as a user profile).

  • Cache-Control "max-age = 3600, must-revalidate" tell both client caches and proxy caches that, when the content is out of date (older than 3600 seconds), they must have a source server before they can serve the content. This should be the default caching behavior, but the must-revalidate directive makes this requirement unique.

Where, after the expiration of the maximum validity period, the client must repeat the check. He can overestimate the use of If-Match or If-None-Match headers with an ETag, or he can use If-Modified-Since or If-Unmodified-Since headers with a date. Thus, after the expiration date, the browser checks on the server whether the file is updated. If not, the server will respond with a 304 Not Modified header and nothing will be loaded.

+1
source

All Articles