Does Cache-Control:no-cache support this setting?

Cache-Control:no-cache is cached but immediately invalidated, and then go to cdn to compare etag. If the etag does not expire, it will return 304to use the local cache, and if it expires, it will return 202to use the newly launched content.

current scenario: how should I use local cache instead of reporting network errors when I go to cdn to compare etag, but the network is not working? Is there such a configuration at the front end? How should it be configured?


cache-control:no-cache means does not cache and directly requests the server (your cdn) to download the file.
etag is a similar file content hash sum,. When the browser downloads the file for the first time, the server sends the etag of the file to the browser and the browser saves it. The next time the file is accessed, the browser sends a request and carries the etag information to the server. The server checks whether the etag is consistent with the target file, and if so, the browser uses the cached copy, otherwise, the new file is downloaded.

if you want to use caching, you need to know the caching strategy you expect. Generally, front-end resources can be divided into two categories, html and others. Set no-cache and etag, for html, to make full use of cache while keeping html up-to-date.
other resources, such as css/js/image, etc., use build tools such as gulp/webpack to hit the hash, of the content in the file and set the max-age as long as possible (usually set for one year).


cache-control: no-cache does not cache, but conditionally uses cache (cache can be used when ETag comparison is consistent and the server returns 304)

Menu