
They can be used to control how frequently a browser caches a file, how long the cache should keep the file, and what should be done when the file is expired. These headers are sent with every HTTP request and response.
#Public vs private cache control how to#
HTTP cache headers are instructions that web servers send to web browsers, telling them how to cache and serve content. Other CDNs use a "push" model, where the origin server sends files to the CDN proactively before they are requested by a browser. Some CDNs use a "pull" model, where the CDN only caches files when they are requested by a browser. This can greatly reduce the amount of time and resources needed to load the file, as the request doesn't need to travel all the way to the origin server.ĬDN caches can be configured in a number of different ways, depending on the needs of the website. If the CDN has a cached copy of the file, it serves it directly to the browser. When a browser requests a file from a website that is using a CDN, the request is sent to the CDN instead of the origin server. CDN cachesĬDN caches are distributed caches that are used by Content Delivery Networks (CDNs) to store copies of files. If the file has expired, or if the browser has been told not to cache it, the browser requests a fresh copy of the file from the server. If it does, and the file hasn't expired, the browser serves the cached version of the file. When a browser requests a file, it first checks its local cache to see if it already has a copy.

Browser cachesīrowser caches are local caches that are used by web browsers to store copies of files. There are two main types of caches: browser caches and CDN caches. If the file has expired or if the browser has been told not to cache it, the browser requests a fresh copy of the file from the server.Ĭaching works differently depending on the type of cache being used.

The next time the browser requests the same file, it checks its cache to see if it already has a copy. The browser then caches the file based on these headers. When a browser requests a file from a server, the server responds with the file and some cache headers. In case you are looking for in-depth information on the role of HTTP cache headers in the modern web, here's everything you need to know. This article highlights important information on HTTP caching headers and associated CDN behavior. These headers tell web browsers and other HTTP clients how to cache and serve content from your website. One of the best ways to achieve this is by using HTTP caching headers.

As a website owner, you want your website to be fast, efficient, and accessible to as many users as possible.
