Is it the filename or the whole URL used as a key in browser caches?

前端 未结 10 1181
旧巷少年郎
旧巷少年郎 2020-12-15 04:24

It\'s common to want browsers to cache resources - JavaScript, CSS, images, etc. until there is a new version available, and then ensure that the browser fetches and caches

10条回答
  •  死守一世寂寞
    2020-12-15 05:04

    Browser cache key is a combination of the request method and resource URI. URI consists of scheme, authority, path, query, and fragment.

    Relevant excerpt from HTTP 1.1 specification:

    The primary cache key consists of the request method and target URI. However, since HTTP caches in common use today are typically limited to caching responses to GET, many caches simply decline other methods and use only the URI as the primary cache key.

    Relevant excerpt from URI specification:

    The generic URI syntax consists of a hierarchical sequence of components referred to as the scheme, authority, path, query, and fragment.

    URI         = scheme ":" hier-part [ "?" query ] [ "#" fragment ]
    
    hier-part   = "//" authority path-abempty
                  / path-absolute
                  / path-rootless
                  / path-empty
    

提交回复
热议问题