Cache-Control Headers

Cache-Control Headers

The performance of content that is available via web sites and applications can be significantly improved by reusing previously fetched resources. Web caches reduce latency and network traffic as well as the time needed to display a representation of a resource. By making use of HTTP caching, Web sites become more responsive.

There are several kinds of caches: these can be grouped into two main categories:

  • private or
  • shared caches

A?shared cache?is a cache that stores responses for reuse by more than one user. A?private cache?is dedicated to a single user.

The primary cache key consists of the request method and target URI (oftentimes only the URI is used as only GET requests are caching targets). Common forms of caching entries are:

  • Successful results of a retrieval request: a?200?(OK) response to a?GET?request containing a resource like HTML documents, or other content available on the website.
  • Permanent redirects: a?301?(Moved Permanently) response.
  • Error responses: a?404?(Not Found) result page.
  • Incomplete results: a?206?(Partial Content) response.

The?Cache-Control HTTP/1.1 general-header field is used to specify directives for caching mechanisms in both requests and responses.

The headers which can be used in the header field are:

Cache-Control: Max-Age

The max-age request directive defines, in seconds, the amount of time it takes for a cached copy of a resource to expire. After expiring, a browser must refresh its version of the resource by sending another request to a server.

Cache-Control: No-Cache

The no-cache directive means that a browser may cache a response, but must first submit a validation request to an origin server.

Cache-Control: No-Store

The no-store directive means browsers aren’t allowed to cache a response and must pull it from the server each time it’s requested. This setting is usually used for sensitive data, such as personal banking details.

Cache-Control: Public

The public response directive indicates that a resource can be cached by any cache.

Cache-Control: Private

The private response directive indicates that a resource is user specific—it can still be cached, but only on a client device. For example, a web page response marked as private can be cached by a desktop browser, but not a content delivery network (CDN).

Additional HTTP Cache Headers

Expires?– This header specifies a fixed date/time for the expiration of a cached resource. The expires header is ignored when a cache-control header containing a max-age directive is present.

ETag?– A response header that identifies the version of served content according to a token – a string of characters in quotes, e.g., “675af34563dc-tr34” – that changes after a resource is modified. If a token is unchanged before a request is made, the browser continues to use its local version.

Vary?– A header that determines the responses that must match a cached resource for it to be considered valid. For example, the header Vary: Accept-Language, User-Agent specifies that a cached version must exist for each combination of user-agent and language.

Sources:


#cacheheader #web #webdevelopment #webapplications #livestreaming #caching






要查看或添加评论,请登录

Andrew Antonopoulos的更多文章

  • Sustainable ML - Monitor Power Consumption

    Sustainable ML - Monitor Power Consumption

    Training models will also consider the power consumption of the hardware. The following paper compares the most common…

  • TensorFlow Serving API & gRPC

    TensorFlow Serving API & gRPC

    To serve models for production applications, one can use REST API or gRPC. gRPC is a high-performance, binary, and…

  • Blockchain & Web3 Technology

    Blockchain & Web3 Technology

    Blockchain is a technology that securely stores transactional information by linking blocks together in a specific…

  • NVIDIA Mixed Precision - Loss & Accuracy - Part 2

    NVIDIA Mixed Precision - Loss & Accuracy - Part 2

    Part 1 explained how Nvidia's mixed precision can help reduce power consumption. However, we also need to consider…

  • NVIDIA Mixed Precision & Power Consumption - Part 1

    NVIDIA Mixed Precision & Power Consumption - Part 1

    Deep Learning has enabled progress in many different applications and can be used for developing models for…

  • Nvidia GPU & TensorFlow for ML in Ubuntu 24.04 LTS

    Nvidia GPU & TensorFlow for ML in Ubuntu 24.04 LTS

    Tensorflow announced that it would stop supporting GPUs for Windows. The latest support version was 2.

    5 条评论
  • FreeBSD 13 & TCP BBR Congestion Control

    FreeBSD 13 & TCP BBR Congestion Control

    Finally TCP BBR is available for FreeBSD new release 13.x.

    2 条评论
  • Kubernetes - Open Source Tools

    Kubernetes - Open Source Tools

    Kubernetes (also known as k8s or “kube”) is a very popular container orchestration platform that automates many of the…

  • CDN Cache and Machine Learning

    CDN Cache and Machine Learning

    The majority of the Internet’s content is delivered by global caching networks, also known as Content Delivery Networks…

  • OTT & Mobile Battle in Africa

    OTT & Mobile Battle in Africa

    OTT and specially SVOD is growing in Africa. Recently big OTT providers such as Netflix, muvi, Showmax, iFlix, MTN and…

社区洞察

其他会员也浏览了