{"id":112,"date":"2017-08-13T14:38:29","date_gmt":"2017-08-13T14:38:29","guid":{"rendered":"https:\/\/www.imperva.com\/learn\/?post_type=performance&#038;p=112"},"modified":"2024-05-22T12:13:02","modified_gmt":"2024-05-22T12:13:02","slug":"cache-control","status":"publish","type":"performance","link":"https:\/\/www.imperva.com\/learn\/performance\/cache-control\/","title":{"rendered":"Cache Control"},"content":{"rendered":"<h2 class=\"t3\">What is the Cache-Control Header<\/h2>\n<p>Cache-control is an HTTP header used to specify\u00a0<a href=\"https:\/\/www.imperva.com\/learn\/performance\/browser-caching\/\" target=\"_blank\" rel=\"noopener noreferrer\">browser caching<\/a>\u00a0policies in both client requests and server responses. Policies include how a resource is cached, where it\u2019s cached and its maximum age before expiring (i.e.,\u00a0<a href=\"https:\/\/www.imperva.com\/learn\/performance\/time-to-live-ttl\/\" target=\"_blank\" rel=\"noopener noreferrer\">time to live<\/a>).<\/p>\n<p>The cache-control header is broken up into directives, the most common of which are detailed below:<\/p>\n<div id=\"attachment_113\" style=\"width: 830px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-113\" class=\"wp-image-113 size-full\" src=\"https:\/\/www.imperva.com\/learn\/wp-content\/uploads\/sites\/13\/2019\/01\/response-headers.jpg\" alt=\"An example of an HTTP Response Header from google.com\" width=\"820\" height=\"386\" srcset=\"https:\/\/www.imperva.com\/learn\/wp-content\/uploads\/sites\/13\/2019\/01\/response-headers.jpg 820w, https:\/\/www.imperva.com\/learn\/wp-content\/uploads\/sites\/13\/2019\/01\/response-headers-300x141.jpg 300w, https:\/\/www.imperva.com\/learn\/wp-content\/uploads\/sites\/13\/2019\/01\/response-headers-768x362.jpg 768w, https:\/\/www.imperva.com\/learn\/wp-content\/uploads\/sites\/13\/2019\/01\/response-headers-670x315.jpg 670w, https:\/\/www.imperva.com\/learn\/wp-content\/uploads\/sites\/13\/2019\/01\/response-headers-510x240.jpg 510w, https:\/\/www.imperva.com\/learn\/wp-content\/uploads\/sites\/13\/2019\/01\/response-headers-106x50.jpg 106w, https:\/\/www.imperva.com\/learn\/wp-content\/uploads\/sites\/13\/2019\/01\/response-headers-660x311.jpg 660w, https:\/\/www.imperva.com\/learn\/wp-content\/uploads\/sites\/13\/2019\/01\/response-headers-420x198.jpg 420w\" sizes=\"auto, (max-width: 820px) 100vw, 820px\" \/><p id=\"caption-attachment-113\" class=\"wp-caption-text\">An example of an HTTP Response Header from google.com<\/p><\/div>\n<h2 class=\"t3\">Cache-Control: Max-Age<\/h2>\n<p>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.<\/p>\n<p>For example,\u00a0<code>cache-control: max-age=120<\/code>\u00a0means that the returned resource is valid for 120 seconds, after which the browser has to request a newer version.<\/p>\n<h2 class=\"t3\">Cache-Control: No-Cache<\/h2>\n<p>The no-cache directive means that a browser may cache a response, but must first submit a validation request to an\u00a0<a href=\"https:\/\/www.imperva.com\/learn\/performance\/origin-server\/\" target=\"_blank\" rel=\"noopener noreferrer\">origin server<\/a>.<\/p>\n<h2 class=\"t3\">Cache-Control: No-Store<\/h2>\n<p>The no-store directive means browsers aren\u2019t allowed to cache a response and must pull it from the server each time it\u2019s requested. This setting is usually used for sensitive data, such as personal banking details.<\/p>\n<h2 class=\"t3\">Cache-Control: Public<\/h2>\n<p>The public response directive indicates that a resource can be cached by any cache.<\/p>\n<h2 class=\"t3\">Cache-Control: Private<\/h2>\n<p>The private response directive indicates that a resource is user specific\u2014it 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).<\/p>\n<h2 class=\"t3\">Additional HTTP Cache Headers<\/h2>\n<p>In addition to cache-control, notable HTTP cache headers include:<\/p>\n<ul>\n<li><strong><span class=\"lato-bold-text\">Expires<\/span><\/strong>\u00a0\u2013 This header specifies a fixed date\/time for the expiration of a cached resource. For example,\u00a0<code>Expires: Sat, 13 May 2017 07:00:00 GMT<\/code> signals that the cached resource expires on May 13, 2017 at 7:00 am GMT. The expires header is respected even if a cache-control header with a max-age directive is present.<\/li>\n<li><strong><span class=\"lato-bold-text\">ETag<\/span><\/strong>\u00a0\u2013 A response header that identifies the version of served content according to a token \u2013 a string of characters in quotes, e.g.,\u00a0<code>\"675af34563dc-tr34\"<\/code>\u00a0\u2013 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.<\/li>\n<li><strong><span class=\"lato-bold-text\">Vary<\/span>\u00a0<\/strong>\u2013 A header that determines the responses that must match a cached resource for it to be considered valid. For example, the header\u00a0<code>Vary: Accept-Language, User-Agent<\/code>\u00a0specifies that a cached version must exist for each combination of user agent and language.<\/li>\n<\/ul>\n<div class=\"ddos-banner\"><div class=\"wrap\"><p>See how Imperva CDN can help you with website performance.<\/p>\n<div class=\"cta-container\">\n                                                    <a class=\"impv-yellow-btn\"  event-action=\"Click\"  event-category=\"LC Banner\"  event-label=\"Request demo\"  gtm-track  target=\"_self\" href=\"javascript:openModal('modalid3533', '\/learn\/banner\/virtual\/request-demo\/', 'Personal Demo Request | Imperva');\">Request demo<\/a>\n                                                    <a class=\"gst-yellow-dark-text-btn\"  event-action=\"Click\"  event-category=\"LC Banner\"  event-label=\"Learn more\"  gtm-track  target=\"_self\" href=\"https:\/\/www.imperva.com\/products\/cdn-content-delivery-network\/\">Learn more<\/a>\n                                                <\/div><\/div><\/div><h2 class=\"t3\">CDNs and Cache-Control<\/h2>\n<p>The variety of caching headers can make manual cache management overwhelming. CDNs allow for granular cache policy management through a user-friendly dashboard, relieving you of the need to manually tweak individual headers.<\/p>\n<p>In addition to simplifying cache management, CDNs augment the browser caching process using proxies. Proxy caching brings content closer to site visitors, accelerating the delivery of locally stored resources. This is especially beneficial for first-time visitors whose browsers have yet to cache site content.<\/p>\n<p>Finally, more advanced CDNs use advanced automation techniques, including machine learning, to cache dynamically generated content and resources. This optimizes your caching policies and further speeds up content delivery.<\/p>\n","protected":false},"featured_media":0,"menu_order":0,"template":"","categories":[7],"class_list":["post-112","performance","type-performance","status-publish","hentry","category-cdn-guide"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>What is Cache-Control and How HTTP Cache Headers Work | CDN Guide | Imperva<\/title>\n<meta name=\"description\" content=\"Learn how HTTP cache-control and other HTTP cache headers can help you manage browser and server-side caching policies.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.imperva.com\/learn\/performance\/cache-control\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"What is Cache-Control and How HTTP Cache Headers Work | CDN Guide | Imperva\" \/>\n<meta property=\"og:description\" content=\"Learn how HTTP cache-control and other HTTP cache headers can help you manage browser and server-side caching policies.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.imperva.com\/learn\/performance\/cache-control\/\" \/>\n<meta property=\"og:site_name\" content=\"Learning Center\" \/>\n<meta property=\"article:modified_time\" content=\"2024-05-22T12:13:02+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.imperva.com\/learn\/wp-content\/uploads\/sites\/13\/2019\/01\/response-headers.jpg\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"3 minutes\" \/>\n\t<meta name=\"twitter:label2\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data2\" content=\"Itamar Verta\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.imperva.com\/learn\/performance\/cache-control\/\",\"url\":\"https:\/\/www.imperva.com\/learn\/performance\/cache-control\/\",\"name\":\"What is Cache-Control and How HTTP Cache Headers Work | CDN Guide | Imperva\",\"isPartOf\":{\"@id\":\"https:\/\/www.imperva.com\/learn\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.imperva.com\/learn\/performance\/cache-control\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.imperva.com\/learn\/performance\/cache-control\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.imperva.com\/learn\/wp-content\/uploads\/sites\/13\/2019\/01\/response-headers.jpg\",\"datePublished\":\"2017-08-13T14:38:29+00:00\",\"dateModified\":\"2024-05-22T12:13:02+00:00\",\"description\":\"Learn how HTTP cache-control and other HTTP cache headers can help you manage browser and server-side caching policies.\",\"breadcrumb\":{\"@id\":\"https:\/\/www.imperva.com\/learn\/performance\/cache-control\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.imperva.com\/learn\/performance\/cache-control\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.imperva.com\/learn\/performance\/cache-control\/#primaryimage\",\"url\":\"https:\/\/www.imperva.com\/learn\/wp-content\/uploads\/sites\/13\/2019\/01\/response-headers.jpg\",\"contentUrl\":\"https:\/\/www.imperva.com\/learn\/wp-content\/uploads\/sites\/13\/2019\/01\/response-headers.jpg\",\"width\":820,\"height\":386},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.imperva.com\/learn\/performance\/cache-control\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.imperva.com\/learn\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Performance\",\"item\":\"https:\/\/www.imperva.com\/learn\/performance\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Cache Control\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.imperva.com\/learn\/#website\",\"url\":\"https:\/\/www.imperva.com\/learn\/\",\"name\":\"Learning Center\",\"description\":\"Imperva\",\"publisher\":{\"@id\":\"https:\/\/www.imperva.com\/learn\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.imperva.com\/learn\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.imperva.com\/learn\/#organization\",\"name\":\"Imperva Inc\",\"url\":\"https:\/\/www.imperva.com\/learn\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.imperva.com\/learn\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.imperva.com\/learn\/wp-content\/uploads\/sites\/13\/2023\/06\/Linkedin-FB-OG-sharing.jpeg\",\"contentUrl\":\"https:\/\/www.imperva.com\/learn\/wp-content\/uploads\/sites\/13\/2023\/06\/Linkedin-FB-OG-sharing.jpeg\",\"width\":1200,\"height\":627,\"caption\":\"Imperva Inc\"},\"image\":{\"@id\":\"https:\/\/www.imperva.com\/learn\/#\/schema\/logo\/image\/\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"What is Cache-Control and How HTTP Cache Headers Work | CDN Guide | Imperva","description":"Learn how HTTP cache-control and other HTTP cache headers can help you manage browser and server-side caching policies.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.imperva.com\/learn\/performance\/cache-control\/","og_locale":"en_US","og_type":"article","og_title":"What is Cache-Control and How HTTP Cache Headers Work | CDN Guide | Imperva","og_description":"Learn how HTTP cache-control and other HTTP cache headers can help you manage browser and server-side caching policies.","og_url":"https:\/\/www.imperva.com\/learn\/performance\/cache-control\/","og_site_name":"Learning Center","article_modified_time":"2024-05-22T12:13:02+00:00","og_image":[{"url":"https:\/\/www.imperva.com\/learn\/wp-content\/uploads\/sites\/13\/2019\/01\/response-headers.jpg","type":"","width":"","height":""}],"twitter_card":"summary_large_image","twitter_misc":{"Est. reading time":"3 minutes","Written by":"Itamar Verta"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.imperva.com\/learn\/performance\/cache-control\/","url":"https:\/\/www.imperva.com\/learn\/performance\/cache-control\/","name":"What is Cache-Control and How HTTP Cache Headers Work | CDN Guide | Imperva","isPartOf":{"@id":"https:\/\/www.imperva.com\/learn\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.imperva.com\/learn\/performance\/cache-control\/#primaryimage"},"image":{"@id":"https:\/\/www.imperva.com\/learn\/performance\/cache-control\/#primaryimage"},"thumbnailUrl":"https:\/\/www.imperva.com\/learn\/wp-content\/uploads\/sites\/13\/2019\/01\/response-headers.jpg","datePublished":"2017-08-13T14:38:29+00:00","dateModified":"2024-05-22T12:13:02+00:00","description":"Learn how HTTP cache-control and other HTTP cache headers can help you manage browser and server-side caching policies.","breadcrumb":{"@id":"https:\/\/www.imperva.com\/learn\/performance\/cache-control\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.imperva.com\/learn\/performance\/cache-control\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.imperva.com\/learn\/performance\/cache-control\/#primaryimage","url":"https:\/\/www.imperva.com\/learn\/wp-content\/uploads\/sites\/13\/2019\/01\/response-headers.jpg","contentUrl":"https:\/\/www.imperva.com\/learn\/wp-content\/uploads\/sites\/13\/2019\/01\/response-headers.jpg","width":820,"height":386},{"@type":"BreadcrumbList","@id":"https:\/\/www.imperva.com\/learn\/performance\/cache-control\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.imperva.com\/learn\/"},{"@type":"ListItem","position":2,"name":"Performance","item":"https:\/\/www.imperva.com\/learn\/performance\/"},{"@type":"ListItem","position":3,"name":"Cache Control"}]},{"@type":"WebSite","@id":"https:\/\/www.imperva.com\/learn\/#website","url":"https:\/\/www.imperva.com\/learn\/","name":"Learning Center","description":"Imperva","publisher":{"@id":"https:\/\/www.imperva.com\/learn\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.imperva.com\/learn\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.imperva.com\/learn\/#organization","name":"Imperva Inc","url":"https:\/\/www.imperva.com\/learn\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.imperva.com\/learn\/#\/schema\/logo\/image\/","url":"https:\/\/www.imperva.com\/learn\/wp-content\/uploads\/sites\/13\/2023\/06\/Linkedin-FB-OG-sharing.jpeg","contentUrl":"https:\/\/www.imperva.com\/learn\/wp-content\/uploads\/sites\/13\/2023\/06\/Linkedin-FB-OG-sharing.jpeg","width":1200,"height":627,"caption":"Imperva Inc"},"image":{"@id":"https:\/\/www.imperva.com\/learn\/#\/schema\/logo\/image\/"}}]}},"_links":{"self":[{"href":"https:\/\/www.imperva.com\/learn\/wp-json\/wp\/v2\/performance\/112","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.imperva.com\/learn\/wp-json\/wp\/v2\/performance"}],"about":[{"href":"https:\/\/www.imperva.com\/learn\/wp-json\/wp\/v2\/types\/performance"}],"version-history":[{"count":7,"href":"https:\/\/www.imperva.com\/learn\/wp-json\/wp\/v2\/performance\/112\/revisions"}],"predecessor-version":[{"id":3030,"href":"https:\/\/www.imperva.com\/learn\/wp-json\/wp\/v2\/performance\/112\/revisions\/3030"}],"wp:attachment":[{"href":"https:\/\/www.imperva.com\/learn\/wp-json\/wp\/v2\/media?parent=112"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.imperva.com\/learn\/wp-json\/wp\/v2\/categories?post=112"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}