Reputation: 1018
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.
First, set Etag on response header.
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.
If the If-None-Match
value is up to date, I just write 304 in the response and send it.
And otherwise, I just respond with the data normally. with the new Etag value.
Upvotes: 0
Views: 634