I have a SPA which consumes some static assets from the backend server. For reasons, I picked ETag
validation as the caching mechanism. In short, I want the browser keep the assets in its cache forever, as long as the related ETag
s remain unchanged.
To signal the browser about caching, header Cache-Control
must be present in the the responses. To me it's absolutely comprehensible, but what makes me confused is that I have to provide max-age
in the header as well. In other words Cache-Control=public
doesn't work whereas Cache-Control=public, max-age=100
is the correct header.
To me it sounds contradictory. The browser inquiries the server to see if an asset has changed using If-Not-Match={ETag}
any time it asks for it. What's the role of max-age
here then?