MINJA KIM
MINJA KIM

Reputation: 1018

Question about Etag and Cache-Control Header

I am trying to customize cache strategy.
because default setting is not fit on me ... Serviced by (Vercel).

I am unfamiliar with the cache setting through the http header, so I would like to ask for help.
Please check if my understanding is correct.


First of all, my response data doesn't change often. But occasionally it changes.

Here is my plan.

Maybe i should revalidate every time. so i need to set my Cache-Control like this.

Cache-Control: public max-age=0 must-revalidate

I guess, with this way, my data will be stored in the client browser
and the browser will always send request that check the value is new.

And on the server, i'll write code to handle the things written in the lines below.

  1. First, set Etag on response header.

  2. Second, if the If-None-Match value comes from the request header, I compare it with my service logic to check whether the value is up to date.

  3. If the If-None-Match value is up to date, I just write 304 in the response and send it.

  4. And otherwise, I just respond with the data normally. with the new Etag value.

Upvotes: 0

Views: 634

Answers (0)

Related Questions