{"id":649,"date":"2023-06-26T08:09:15","date_gmt":"2023-06-26T08:09:15","guid":{"rendered":"https:\/\/blog.hostinger.io\/support\/2023\/06\/26\/8052370-advanced-cdn-header-management-at-hostinger\/"},"modified":"2026-03-16T12:12:02","modified_gmt":"2026-03-16T12:12:02","slug":"8052370-advanced-cdn-header-management-at-hostinger","status":"publish","type":"post","link":"https:\/\/www.hostinger.com\/support\/8052370-advanced-cdn-header-management-at-hostinger\/","title":{"rendered":"Advanced CDN Header Management at Hostinger"},"content":{"rendered":"<p class=\"no-margin\">A <code>Cache-Control<\/code> header is an HTTP header field that allows the server to specify caching directives for the client (such as a web browser) and intermediate caches (such as proxy servers). It controls how the client and caches should store and reuse the response to subsequent requests. It also provides a way to control various aspects of caching, including caching lifespan, cache validation, and cache revalidation.<\/p><div class=\"intercom-interblocks-callout\" style=\"background-color: #e3e7fa80;border-color: #334bfa33\">\n<p class=\"no-margin\">Learn more: <b><a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/HTTP\/Headers\/Cache-Control\" target=\"_blank\" class=\"intercom-content-link\" rel=\"noopener\">Mozilla Cache-Control documentation<\/a> &#128161; <\/b><\/p>\n<\/div><p class=\"no-margin\">If <b>multiple directives<\/b> are passed together, each directive is separated by a <b>comma<\/b> ( , ). If the directive<b> takes an argument<\/b>, it follows the directive separated by an <b>equal sign<\/b> ( <b>= <\/b>), e.g., <code>max-age=86400<\/code>.<\/p><p class=\"no-margin\">\n<\/p><p class=\"no-margin\"><code>Cache-Control<\/code> headers can be customized in the <b><a href=\"https:\/\/support.hostinger.com\/en\/collections\/3185639-htaccess\" target=\"_blank\" class=\"intercom-content-link\" rel=\"noopener\">.htaccess<\/a><\/b> file or via <b><a href=\"https:\/\/www.php.net\/manual\/en\/function.header.php#:~:text=Example%20%232%20Caching%20directives\" target=\"_blank\" class=\"intercom-content-link\" rel=\"noopener\">PHP code<\/a><\/b>.<\/p><p class=\"no-margin\">\n<\/p><h2 id=\"h_21483c5ffa\">Types of Directives<\/h2><p class=\"no-margin\">Directives can be broken down into <b>four groups<\/b>: cacheability, expiration, revalidation, and others.<\/p><p class=\"no-margin\">\n<\/p><h3 id=\"h_44830fd2f9\">Cacheability<\/h3><p class=\"no-margin\">It refers to <b>whether or not a resource should enter a cache<\/b>, and the directives below indicate a resource&rsquo;s cacheability:<\/p><ul>\n<li>\n<p class=\"no-margin\"><code>public<\/code> &mdash; indicates any cache may store the response, even if the response is normally non-cacheable or cacheable only within a private cache<\/p>\n<\/li>\n<li>\n<p class=\"no-margin\"><code>private<\/code> &mdash; indicates the response message is intended for a single user (e.g., a browser cache) and must not be stored by a shared cache on CDN or a corporate proxy<\/p>\n<\/li>\n<li>\n<p class=\"no-margin\"><code>no-store<\/code> &mdash; indicates any cache (i.e., a client or proxy cache) must not store any part of either the immediate request or response<\/p>\n<\/li>\n<\/ul><h3 id=\"h_c5a07b1d52\">Expiration<\/h3><p class=\"no-margin\">It refers to <b>how long a resource should remain in the cache<\/b>, and the directives below affect how long a resource stays in the cache:<\/p><ul>\n<li>\n<p class=\"no-margin\"><code>max-age=seconds<\/code> &mdash; indicates the response is stale after its age is greater than the specified number of seconds<\/p>\n<ul>\n<li>\n<p class=\"no-margin\">Age is defined as the time in seconds since the asset was served from the origin server<\/p>\n<\/li>\n<li>\n<p class=\"no-margin\">The <code>seconds<\/code> argument is an unquoted integer<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p class=\"no-margin\"><code>s-maxage=seconds<\/code> &mdash; indicates that in shared caches, the maximum age specified by this directive overrides the maximum age specified by either the <code>max-age<\/code> directive or the <code>Expires<\/code> header field<\/p>\n<ul>\n<li>\n<p class=\"no-margin\">The <code>s-maxage<\/code> directive also implies the semantics of the proxy-revalidate response directive<\/p>\n<\/li>\n<li>\n<p class=\"no-margin\">Browsers ignore <code>s-maxage<\/code><\/p>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p class=\"no-margin\"><code>no-cache<\/code> &mdash; indicates the response cannot be used to satisfy a subsequent request without successful validation on the origin server; this allows an origin server to prevent a cache from using the origin to satisfy a request without contacting it, even by caches that have been configured to send stale responses<\/p>\n<\/li>\n<\/ul><div class=\"intercom-interblocks-callout\" style=\"background-color: #e3e7fa80;border-color: #334bfa33\">\n<p class=\"no-margin\">Ensure the HTTP <code>Expires<\/code> header is set in your origin server to use <b>Greenwich Mean Time (GMT)<\/b> as stipulated in <b><a href=\"https:\/\/www.w3.org\/Protocols\/rfc2616\/rfc2616-sec3.html#sec3.3\" target=\"_blank\" class=\"intercom-content-link\" rel=\"noopener\">RFC 2616Open external link<\/a><\/b> &#128161; <\/p>\n<\/div><p class=\"no-margin\">\n<\/p><h3 id=\"h_2906bead30\">Revalidation<\/h3><p class=\"no-margin\">It refers to <b>how and when a cache should revalidate a cached response<\/b> with the server to ensure it is still valid and up to date.<\/p><p class=\"no-margin\">\n<\/p><p class=\"no-margin\">An example of such type of directive is the <code>must-revalidate<\/code> directive. When included in the Cache-Control header, it instructs caches to revalidate a cached response with the server on every subsequent request, even if the response is considered fresh according to the expiration time specified by the <code>max-age<\/code> directive. This ensures that the cache serves only up-to-date responses and helps maintain data integrity.<\/p><p class=\"no-margin\">\n<\/p><h3 id=\"h_ef04a0d50e\">Other<\/h3><p class=\"no-margin\">This group includes additional directives that control various aspects of caching, such as forcing caches to revalidate responses, preventing storage of responses in caches, or requiring the use of conditional requests for validation.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Learn about cache control header types and directives<\/p>\n","protected":false},"author":581,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"include_on_kodee":true,"footnotes":""},"categories":[262],"tags":[],"class_list":["post-649","post","type-post","status-publish","format-standard","hentry","category-cdn"],"hreflangs":[{"locale":"en-US","link":"https:\/\/www.hostinger.com\/support\/8052370-advanced-cdn-header-management-at-hostinger\/","default":1}],"include_on_kodee":true,"_links":{"self":[{"href":"https:\/\/www.hostinger.com\/support\/wp-json\/wp\/v2\/posts\/649","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.hostinger.com\/support\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.hostinger.com\/support\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.hostinger.com\/support\/wp-json\/wp\/v2\/users\/581"}],"replies":[{"embeddable":true,"href":"https:\/\/www.hostinger.com\/support\/wp-json\/wp\/v2\/comments?post=649"}],"version-history":[{"count":0,"href":"https:\/\/www.hostinger.com\/support\/wp-json\/wp\/v2\/posts\/649\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.hostinger.com\/support\/wp-json\/wp\/v2\/media?parent=649"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.hostinger.com\/support\/wp-json\/wp\/v2\/categories?post=649"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.hostinger.com\/support\/wp-json\/wp\/v2\/tags?post=649"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}