{"id":429,"date":"2012-02-01T11:13:35","date_gmt":"2012-02-01T11:13:35","guid":{"rendered":"http:\/\/blog.belvg.com\/?p=429"},"modified":"2019-03-28T11:56:10","modified_gmt":"2019-03-28T09:56:10","slug":"cache-control-header","status":"publish","type":"post","link":"https:\/\/belvg.com\/blog\/cache-control-header.html","title":{"rendered":"Cache-Control Header"},"content":{"rendered":"<p>One of the most flexible caching tools is the Cache-Control header. It supports a number of directives that can be specified by commas. For example,<\/p>\n<pre>Cache-Control: max-age = 3600, must-revalidate<\/pre>\n<p>Below we mention acceptable directives for the header response.<\/p>\n<p><!--more--><\/p>\n<table class=\"cache-table\">\n<tbody>\n<tr>\n<th style=\"width: 120px;\">Directive<\/th>\n<th>Description<\/th>\n<\/tr>\n<tr>\n<td><strong>max-age=n<\/strong><\/td>\n<td>Sets the expiration date of the response equal to n seconds after the request. As opposed to Expires, it eliminates concerns about time synchronization and the expiration date update.<\/td>\n<\/tr>\n<tr>\n<td><strong>s-maxage=n<\/strong><\/td>\n<td>The same as max-age, but is applicable to shared (proxy) cache.<\/td>\n<\/tr>\n<tr>\n<td><strong>Public<\/strong><\/td>\n<td>Enables caching of requests, secured with authentication, which by default are not cacheable.<\/td>\n<\/tr>\n<tr>\n<td><strong>Private<\/strong><\/td>\n<td>Enables caching only in single-user caches (i.e., browsers), forbidding it in shared ones. It is applied, for example, when different users are given different versions of the page. However, this method does not guarantee the data confidentiality. To ensure the latter, it is recommended to use the encrypted protocol HTTPS, which generally is not cacheable at all.<\/td>\n<\/tr>\n<tr>\n<td><strong>no-cache<\/strong><\/td>\n<td>Requires the cache to send all requests to the source server for verifying the recency of the response, stored in the cache. It is used when it&#8217;s necessary to maintain semantic transparency without losing benefits of conditional caching.<\/td>\n<\/tr>\n<tr>\n<td><strong>no-store<\/strong><\/td>\n<td>Forbids caching the response under any conditions. As well as private, it is not a reliable instrument for protecting information from third parties.<\/td>\n<\/tr>\n<tr>\n<td><strong>must-revalidate<\/strong><\/td>\n<td>Requires the cache to precisely follow the information about the recency of the stored response. Typically, under certain circumstances (e.g., no internet connection) HTTP allows using the expired cache. Indicating this header, you report a strong need to follow the established rules.<\/td>\n<\/tr>\n<tr>\n<td><strong>proxy-revalidate<\/strong><\/td>\n<td>The same as must-revalidate, but is applicable to shared cache.<\/td>\n<\/tr>\n<tr>\n<td><strong>no-transform<\/strong><\/td>\n<td>Some proxy servers can convert headers and even the body of the response (change picture format, append headers, revise their order, etc.). This directive forbids any actions of that kind.<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>In case of designating conflicting directives, more transparent ones are in priority (they provide the recency of data supplied to clients). In its turn, max-age directive is in higher priority than Expires header.<\/p>\n<p>With that said, to return required HTTP headers of Cache-Control, it&#8217;s necessary to add in one of the above-mentioned configuration files the following lines:<\/p>\n<pre>        Header set Cache-control: private\r\n\r\n    Header set Cache-control: public<\/pre>\n<p>This fragment of Apache web server&#8217;s configuration file checks the mod_headers presence. If the mod_headers module is available, it activates Cache-Control Http-header response: private for all files with .css and .js extensions and public for all files with the .gif, .jpg and .png extensions.<\/p>\n<p><strong>ETag<\/strong><\/p>\n<p>Along with Expires and Cache-Control headers the web server sends the ETag header &#8211; a unique ID for each version of the file. When the server forwards the file to the browser, it marks it at the same time. Later the browser checks whether the newest version is available by sending the HTTP request that includes the If-None-Match header with the last saved ETag value for the requested file. If the content is changed, the server will send a new version of the file. Otherwise, the browser will receive 304 Not modified status and load the file version, already existing in cache. Thus, there is a saving of Web server resources and bandwidth and reducing the page loading total time.<\/p>\n<p>As far as web server nginx finds more use, I will give an example of header configurations for it:<\/p>\n<pre>location ~* \\.(gif|jpg|jpeg|pdf|txt|css|js|png|ico|xml|xml|gz)$ {\r\naccess_log  off;\r\n\texpires max;\r\n\tadd_header  Last-Modified: $date_gmt;\r\n        add_header  Cache-Control  private;\r\n}<\/pre>\n<p><strong>Expect to read caching recommendations and cache proxies&#8217; tricks on February, 8.<\/strong><\/p>\n","protected":false},"excerpt":{"rendered":"One of the most flexible caching tools is the Cache-Control header. It supports a number &#8230;","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[14,34],"tags":[36,37,40],"class_list":["post-429","post","type-post","status-publish","format-standard","hentry","category-magento","category-tipstricks","tag-cache","tag-load-balancing","tag-optimization"],"acf":[],"aioseo_notices":[],"aioseo_head":"\n\t\t<!-- All in One SEO 5.0.4 - aioseo.com -->\n\t<meta name=\"description\" content=\"One of the most flexible caching tools is the Cache-Control header. It supports a number of directives that can be specified by commas.\" \/>\n\t<meta name=\"robots\" content=\"max-image-preview:large\" \/>\n\t<meta name=\"author\" content=\"Pavel Novitsky\"\/>\n\t<link rel=\"canonical\" href=\"https:\/\/belvg.com\/blog\/cache-control-header.html\" \/>\n\t\t<meta name=\"generator\" content=\"All in One SEO (AIOSEO) 5.0.4\" \/>\n\t\t<script type=\"application\/ld+json\" class=\"aioseo-schema\">\n\t\t\t{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/cache-control-header.html#article\",\"name\":\"Cache-Control Header | BelVG Blog\",\"headline\":\"Cache-Control Header\",\"author\":{\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/author\\\/luge#author\"},\"publisher\":{\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/#organization\"},\"datePublished\":\"2012-02-01T11:13:35+02:00\",\"dateModified\":\"2019-03-28T11:56:10+02:00\",\"inLanguage\":\"en-US\",\"commentCount\":5,\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/cache-control-header.html#webpage\"},\"isPartOf\":{\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/cache-control-header.html#webpage\"},\"articleSection\":\"Magento, Tips&amp;Tricks, cache, load balancing, optimization\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/cache-control-header.html#breadcrumblist\",\"itemListElement\":[{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/#listItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/belvg.com\\\/blog\\\/\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/category\\\/magento#listItem\",\"name\":\"Magento\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/category\\\/magento#listItem\",\"position\":2,\"name\":\"Magento\",\"item\":\"https:\\\/\\\/belvg.com\\\/blog\\\/category\\\/magento\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/cache-control-header.html#listItem\",\"name\":\"Cache-Control Header\"},\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/#listItem\",\"name\":\"Home\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/cache-control-header.html#listItem\",\"position\":3,\"name\":\"Cache-Control Header\",\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/category\\\/magento#listItem\",\"name\":\"Magento\"}}]},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/#organization\",\"name\":\"BelVG Blog\",\"description\":\"Magento and Prestashop articles\",\"url\":\"https:\\\/\\\/belvg.com\\\/blog\\\/\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/author\\\/luge#author\",\"url\":\"https:\\\/\\\/belvg.com\\\/blog\\\/author\\\/luge\",\"name\":\"Pavel Novitsky\",\"image\":{\"@type\":\"ImageObject\",\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/cache-control-header.html#authorImage\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/2c4388e3468896377123f434a9a2a2d64f479816da1570f85619b074102127b7?s=96&d=mm&r=g\",\"width\":96,\"height\":96,\"caption\":\"Pavel Novitsky\"}},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/cache-control-header.html#webpage\",\"url\":\"https:\\\/\\\/belvg.com\\\/blog\\\/cache-control-header.html\",\"name\":\"Cache-Control Header | BelVG Blog\",\"description\":\"One of the most flexible caching tools is the Cache-Control header. It supports a number of directives that can be specified by commas.\",\"inLanguage\":\"en-US\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/#website\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/cache-control-header.html#breadcrumblist\"},\"author\":{\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/author\\\/luge#author\"},\"creator\":{\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/author\\\/luge#author\"},\"datePublished\":\"2012-02-01T11:13:35+02:00\",\"dateModified\":\"2019-03-28T11:56:10+02:00\"},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/belvg.com\\\/blog\\\/\",\"name\":\"BelVG Blog\",\"description\":\"Magento and Prestashop articles\",\"inLanguage\":\"en-US\",\"publisher\":{\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/#organization\"}}]}\n\t\t<\/script>\n\t\t<!-- All in One SEO -->\n\n","aioseo_head_json":{"title":"Cache-Control Header | BelVG Blog","description":"One of the most flexible caching tools is the Cache-Control header. It supports a number of directives that can be specified by commas.","canonical_url":"https:\/\/belvg.com\/blog\/cache-control-header.html","robots":"max-image-preview:large","keywords":"","webmasterTools":{"miscellaneous":""},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/belvg.com\/blog\/cache-control-header.html#article","name":"Cache-Control Header | BelVG Blog","headline":"Cache-Control Header","author":{"@id":"https:\/\/belvg.com\/blog\/author\/luge#author"},"publisher":{"@id":"https:\/\/belvg.com\/blog\/#organization"},"datePublished":"2012-02-01T11:13:35+02:00","dateModified":"2019-03-28T11:56:10+02:00","inLanguage":"en-US","commentCount":5,"mainEntityOfPage":{"@id":"https:\/\/belvg.com\/blog\/cache-control-header.html#webpage"},"isPartOf":{"@id":"https:\/\/belvg.com\/blog\/cache-control-header.html#webpage"},"articleSection":"Magento, Tips&amp;Tricks, cache, load balancing, optimization"},{"@type":"BreadcrumbList","@id":"https:\/\/belvg.com\/blog\/cache-control-header.html#breadcrumblist","itemListElement":[{"@type":"ListItem","@id":"https:\/\/belvg.com\/blog\/#listItem","position":1,"name":"Home","item":"https:\/\/belvg.com\/blog\/","nextItem":{"@type":"ListItem","@id":"https:\/\/belvg.com\/blog\/category\/magento#listItem","name":"Magento"}},{"@type":"ListItem","@id":"https:\/\/belvg.com\/blog\/category\/magento#listItem","position":2,"name":"Magento","item":"https:\/\/belvg.com\/blog\/category\/magento","nextItem":{"@type":"ListItem","@id":"https:\/\/belvg.com\/blog\/cache-control-header.html#listItem","name":"Cache-Control Header"},"previousItem":{"@type":"ListItem","@id":"https:\/\/belvg.com\/blog\/#listItem","name":"Home"}},{"@type":"ListItem","@id":"https:\/\/belvg.com\/blog\/cache-control-header.html#listItem","position":3,"name":"Cache-Control Header","previousItem":{"@type":"ListItem","@id":"https:\/\/belvg.com\/blog\/category\/magento#listItem","name":"Magento"}}]},{"@type":"Organization","@id":"https:\/\/belvg.com\/blog\/#organization","name":"BelVG Blog","description":"Magento and Prestashop articles","url":"https:\/\/belvg.com\/blog\/"},{"@type":"Person","@id":"https:\/\/belvg.com\/blog\/author\/luge#author","url":"https:\/\/belvg.com\/blog\/author\/luge","name":"Pavel Novitsky","image":{"@type":"ImageObject","@id":"https:\/\/belvg.com\/blog\/cache-control-header.html#authorImage","url":"https:\/\/secure.gravatar.com\/avatar\/2c4388e3468896377123f434a9a2a2d64f479816da1570f85619b074102127b7?s=96&d=mm&r=g","width":96,"height":96,"caption":"Pavel Novitsky"}},{"@type":"WebPage","@id":"https:\/\/belvg.com\/blog\/cache-control-header.html#webpage","url":"https:\/\/belvg.com\/blog\/cache-control-header.html","name":"Cache-Control Header | BelVG Blog","description":"One of the most flexible caching tools is the Cache-Control header. It supports a number of directives that can be specified by commas.","inLanguage":"en-US","isPartOf":{"@id":"https:\/\/belvg.com\/blog\/#website"},"breadcrumb":{"@id":"https:\/\/belvg.com\/blog\/cache-control-header.html#breadcrumblist"},"author":{"@id":"https:\/\/belvg.com\/blog\/author\/luge#author"},"creator":{"@id":"https:\/\/belvg.com\/blog\/author\/luge#author"},"datePublished":"2012-02-01T11:13:35+02:00","dateModified":"2019-03-28T11:56:10+02:00"},{"@type":"WebSite","@id":"https:\/\/belvg.com\/blog\/#website","url":"https:\/\/belvg.com\/blog\/","name":"BelVG Blog","description":"Magento and Prestashop articles","inLanguage":"en-US","publisher":{"@id":"https:\/\/belvg.com\/blog\/#organization"}}]}},"aioseo_meta_data":{"post_id":"429","title":"Cache-Control Header | #site_title","description":"One of the most flexible caching tools is the Cache-Control header. It supports a number of directives that can be specified by commas.","keywords":[{"label":"Cache-Control Header","value":"Cache-Control Header"}],"keyphrases":null,"focus_keyword":null,"additional_keywords":null,"truseo_locale":null,"primary_term":null,"canonical_url":null,"og_title":null,"og_description":null,"og_object_type":"default","og_image_type":"default","og_image_custom_url":null,"og_image_custom_fields":null,"og_image_url":null,"og_image_width":null,"og_image_height":null,"og_video":null,"og_custom_url":null,"og_article_section":null,"og_article_tags":null,"twitter_use_og":false,"twitter_card":"default","twitter_image_type":"default","twitter_image_custom_url":null,"twitter_image_custom_fields":null,"twitter_image_url":null,"twitter_title":null,"twitter_description":null,"schema_type":"default","schema_type_options":null,"schema":{"blockGraphs":[],"customGraphs":[],"default":{"data":{"Article":[],"Course":[],"Dataset":[],"FAQPage":[],"Movie":[],"Person":[],"Product":[],"ProductReview":[],"Car":[],"Recipe":[],"Service":[],"SoftwareApplication":[],"WebPage":[]},"graphName":"","isEnabled":true},"graphs":[]},"pillar_content":false,"robots_default":true,"robots_noindex":false,"robots_noarchive":false,"robots_nosnippet":false,"robots_nofollow":false,"robots_noimageindex":false,"robots_noodp":false,"robots_notranslate":false,"robots_max_snippet":null,"robots_max_videopreview":null,"robots_max_imagepreview":"large","priority":null,"frequency":null,"local_seo":null,"limit_modified_date":false,"ai":null,"breadcrumb_settings":null,"seo_analyzer_scan_date":null,"created":"2026-11-03 18:38:30","updated":"2026-11-03 18:38:30"},"aioseo_breadcrumb":"<div class=\"aioseo-breadcrumbs\"><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"https:\/\/belvg.com\/blog\/\" title=\"Home\">Home<\/a>\n\t\t<\/span><span class=\"aioseo-breadcrumb-separator\">\u00bb<\/span><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"https:\/\/belvg.com\/blog\/category\/magento\" title=\"Magento\">Magento<\/a>\n\t\t<\/span><span class=\"aioseo-breadcrumb-separator\">\u00bb<\/span><span class=\"aioseo-breadcrumb\">\n\t\t\tCache-Control Header\n\t\t<\/span><\/div>","aioseo_breadcrumb_json":[{"label":"Home","link":"https:\/\/belvg.com\/blog\/"},{"label":"Magento","link":"https:\/\/belvg.com\/blog\/category\/magento"},{"label":"Cache-Control Header","link":"https:\/\/belvg.com\/blog\/cache-control-header.html"}],"post_mailing_queue_ids":[],"_links":{"self":[{"href":"https:\/\/belvg.com\/blog\/wp-json\/wp\/v2\/posts\/429","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/belvg.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/belvg.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/belvg.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/belvg.com\/blog\/wp-json\/wp\/v2\/comments?post=429"}],"version-history":[{"count":27,"href":"https:\/\/belvg.com\/blog\/wp-json\/wp\/v2\/posts\/429\/revisions"}],"predecessor-version":[{"id":21131,"href":"https:\/\/belvg.com\/blog\/wp-json\/wp\/v2\/posts\/429\/revisions\/21131"}],"wp:attachment":[{"href":"https:\/\/belvg.com\/blog\/wp-json\/wp\/v2\/media?parent=429"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/belvg.com\/blog\/wp-json\/wp\/v2\/categories?post=429"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/belvg.com\/blog\/wp-json\/wp\/v2\/tags?post=429"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}