{"id":12346,"date":"2021-11-09T07:48:41","date_gmt":"2021-11-09T07:48:41","guid":{"rendered":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/?p=12346"},"modified":"2023-01-28T11:15:08","modified_gmt":"2023-01-28T11:15:08","slug":"configure-mod-expires-headers","status":"publish","type":"post","link":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/configure-mod-expires-headers\/","title":{"rendered":"How to configure mod_expires headers to manage cache?"},"content":{"rendered":"<h2>&nbsp;What is mod_expires?<\/h2>\n<p>Mod_expires is an Apache module that instructs web browsers on how to manage the cache. The <em>mod_expires<\/em> values inform web browsers about how long to store images, HTML files, and so on. Such configurations will result in quicker page load times for subsequent requests from the same user.<\/p>\n<div class=\"kb-wisdom-wrapr kb-wisdom-info\">\n<div class=\"kb-wisdom-col kb-wisdom-col-icon\">\n<div class=\"kb-wisdom-icon\">\n<div><\/div>\n<\/div>\n<\/div>\n<div class=\"kb-wisdom-col kb-wisdom-col-content\">\n<p>The <em>mod_expires&nbsp;<\/em>module manages the setting of the <em>Expires <\/em>HTTP header and the <em>max-age<\/em> directive of the <em>Cache-Control<\/em> HTTP header in server responses. The expiration date can be specified to be relative to either the last time the source file was last modified or the time the client accessed the file.<\/p>\n<\/div>\n<\/div>\n<p style=\"text-align: left;\">Apache mod_expires page<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-12347\" src=\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/wp-content\/uploads\/2021\/11\/image1.png\" alt=\"\" width=\"1213\" height=\"492\" srcset=\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/wp-content\/uploads\/2021\/11\/image1.png 1213w, https:\/\/www.milesweb.co.uk\/hosting-faqs\/wp-content\/uploads\/2021\/11\/image1-300x122.png 300w, https:\/\/www.milesweb.co.uk\/hosting-faqs\/wp-content\/uploads\/2021\/11\/image1-768x312.png 768w, https:\/\/www.milesweb.co.uk\/hosting-faqs\/wp-content\/uploads\/2021\/11\/image1-1024x415.png 1024w\" sizes=\"auto, (max-width: 1213px) 100vw, 1213px\" \/><\/p>\n<p>Use the following code to verify if the expires module is loaded:<\/p>\n<pre class=\"lang:default decode:true \">httpd -M | grep expires<\/pre>\n<pre class=\"lang:default decode:true\">#[root@web \/]# httpd -M | grep expires\nexpires_module (static)\n[root@web \/]#<\/pre>\n<h2>&nbsp;Configuring mod_expires rules<\/h2>\n<p>You can configure <strong>mod_expires<\/strong> rules in the <strong>.htaccess<\/strong> file from the root directory of your site.<\/p>\n<p>Example:<\/p>\n<pre class=\"lang:default decode:true\">&lt;IfModule mod_expires.c&gt;\nExpiresActive On\nExpiresByType image\/jpg \"access plus 1 year\"\nExpiresByType image\/jpeg \"access plus 1 year\"\nExpiresByType image\/gif \"access plus 1 year\"\nExpiresByType image\/png \"access plus 1 year\"\nExpiresByType text\/css \"access plus 1 month\"\nExpiresByType application\/pdf \"access plus 1 month\"\nExpiresByType text\/x-javascript \"access plus 1 month\"\nExpiresByType application\/javascript \"access plus 1 month\"\nExpiresByType image\/x-icon \"access plus 1 year\"\n\n#default expiry time\nExpiresDefault \"access plus 2 days\"\n&lt;\/IfModule&gt;<\/pre>\n<p>You can add or remove MIME types as per your needs. You can use the above as a template.<\/p>\n<p>The objective is to specify which MIME types should be cached. Begin each line with ExpiresByType, then MIME type followed by time period.<\/p>\n<h2>Testing if mod_expires works<\/h2>\n<p>Use the <em><strong>curl<\/strong><\/em> command to access a file from the site if you have SSH access.<\/p>\n<pre class=\"lang:default decode:true\">curl -is https:\/\/example.co.uk\/file<\/pre>\n<p>For accessing a png file, here is an example:<\/p>\n<pre class=\"lang:default decode:true \">[root@web \/]# curl -is https:\/\/demo.milesweb.co.uk\/logo.png\nHTTP\/2 200\ndate: Tue 9 November 2021 14:40:22 GMT\nserver: Apache\/2\nlast-modified: Fri, 10 February 2018 23:58:37 GMT\netag: \"244c-4d58fcdd26540\"\naccept-ranges: bytes\ncontent-length: 9292\ncache-control: max-age=31536000\nexpires: Wed, 9 November 2022 14:40:22 GMT\ncontent-type: image\/png\n\n[root@web \/]#<\/pre>\n<p>The above example explains that the server is instructing the client to cache the file for one year i.e. from the present date till 9 November 2022.<\/p>\n<p>Related Article:&nbsp;<a href=\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/learn-to-configure-caching-with-the-mod_expires-module\/\" target=\"_blank\" rel=\"noopener\">Learn to configure caching with the mod_expires module<\/a><\/p>\n<p>That is how you can manage the cache on your web browser using Apache module mod_expires.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>&nbsp;What is mod_expires? Mod_expires is an Apache module that instructs web browsers on how to manage the cache. The mod_expires values inform web browsers about how long to store images, HTML files, and so on. Such configurations will result in quicker page load times for subsequent requests from the same user. The mod_expires&nbsp;module manages the [&hellip;]<\/p>\n","protected":false},"author":25,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[41],"tags":[2685,2684,2686,2687],"class_list":["post-12346","post","type-post","status-publish","format-standard","placeholder-for-hentry","category-howtos","tag-apache-mod_expires","tag-manage-cache","tag-mod_expires","tag-mod_expires-headers"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v25.2 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>How to Configure MOD_EXPIRES Headers to Manage Cache<\/title>\n<meta name=\"description\" content=\"The knowledge base explains how you can configure apache MOD_EXPIRES headers to manage cache in web browsers.\" \/>\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.milesweb.co.uk\/hosting-faqs\/configure-mod-expires-headers\/\" \/>\n<meta property=\"og:locale\" content=\"en_GB\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to Configure MOD_EXPIRES Headers to Manage Cache\" \/>\n<meta property=\"og:description\" content=\"The knowledge base explains how you can configure apache MOD_EXPIRES headers to manage cache in web browsers.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/configure-mod-expires-headers\/\" \/>\n<meta property=\"og:site_name\" content=\"Web Hosting FAQs by MilesWeb\" \/>\n<meta property=\"article:published_time\" content=\"2021-11-09T07:48:41+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-01-28T11:15:08+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/wp-content\/uploads\/2021\/11\/image1.png\" \/>\n<meta name=\"author\" content=\"Prajakta Marathe\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Prajakta Marathe\" \/>\n\t<meta name=\"twitter:label2\" content=\"Estimated reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/configure-mod-expires-headers\/\",\"url\":\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/configure-mod-expires-headers\/\",\"name\":\"How to Configure MOD_EXPIRES Headers to Manage Cache\",\"isPartOf\":{\"@id\":\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/configure-mod-expires-headers\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/configure-mod-expires-headers\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/wp-content\/uploads\/2021\/11\/image1.png\",\"datePublished\":\"2021-11-09T07:48:41+00:00\",\"dateModified\":\"2023-01-28T11:15:08+00:00\",\"author\":{\"@id\":\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/#\/schema\/person\/e46bb3e1613b47b1975e8635509d1770\"},\"description\":\"The knowledge base explains how you can configure apache MOD_EXPIRES headers to manage cache in web browsers.\",\"breadcrumb\":{\"@id\":\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/configure-mod-expires-headers\/#breadcrumb\"},\"inLanguage\":\"en-GB\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/configure-mod-expires-headers\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-GB\",\"@id\":\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/configure-mod-expires-headers\/#primaryimage\",\"url\":\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/wp-content\/uploads\/2021\/11\/image1.png\",\"contentUrl\":\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/wp-content\/uploads\/2021\/11\/image1.png\",\"width\":1213,\"height\":492},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/configure-mod-expires-headers\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to configure mod_expires headers to manage cache?\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/#website\",\"url\":\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/\",\"name\":\"Web Hosting FAQs by MilesWeb\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-GB\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/#\/schema\/person\/e46bb3e1613b47b1975e8635509d1770\",\"name\":\"Prajakta Marathe\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-GB\",\"@id\":\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/9dfa3db3773d6f2f050e32c73f20638d?s=96&d=blank&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/9dfa3db3773d6f2f050e32c73f20638d?s=96&d=blank&r=g\",\"caption\":\"Prajakta Marathe\"},\"description\":\"Prajakta is a content writer at MilesWeb. She is ardent about writing technical and non-technical blogs. Adding value to know-how is what she believes in. She also has good experience in educational field. Gratified in sharing knowledge.\",\"url\":\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/author\/prajakta-marathe\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to Configure MOD_EXPIRES Headers to Manage Cache","description":"The knowledge base explains how you can configure apache MOD_EXPIRES headers to manage cache in web browsers.","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.milesweb.co.uk\/hosting-faqs\/configure-mod-expires-headers\/","og_locale":"en_GB","og_type":"article","og_title":"How to Configure MOD_EXPIRES Headers to Manage Cache","og_description":"The knowledge base explains how you can configure apache MOD_EXPIRES headers to manage cache in web browsers.","og_url":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/configure-mod-expires-headers\/","og_site_name":"Web Hosting FAQs by MilesWeb","article_published_time":"2021-11-09T07:48:41+00:00","article_modified_time":"2023-01-28T11:15:08+00:00","og_image":[{"url":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/wp-content\/uploads\/2021\/11\/image1.png","type":"","width":"","height":""}],"author":"Prajakta Marathe","twitter_misc":{"Written by":"Prajakta Marathe","Estimated reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/configure-mod-expires-headers\/","url":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/configure-mod-expires-headers\/","name":"How to Configure MOD_EXPIRES Headers to Manage Cache","isPartOf":{"@id":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/configure-mod-expires-headers\/#primaryimage"},"image":{"@id":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/configure-mod-expires-headers\/#primaryimage"},"thumbnailUrl":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/wp-content\/uploads\/2021\/11\/image1.png","datePublished":"2021-11-09T07:48:41+00:00","dateModified":"2023-01-28T11:15:08+00:00","author":{"@id":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/#\/schema\/person\/e46bb3e1613b47b1975e8635509d1770"},"description":"The knowledge base explains how you can configure apache MOD_EXPIRES headers to manage cache in web browsers.","breadcrumb":{"@id":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/configure-mod-expires-headers\/#breadcrumb"},"inLanguage":"en-GB","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.milesweb.co.uk\/hosting-faqs\/configure-mod-expires-headers\/"]}]},{"@type":"ImageObject","inLanguage":"en-GB","@id":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/configure-mod-expires-headers\/#primaryimage","url":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/wp-content\/uploads\/2021\/11\/image1.png","contentUrl":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/wp-content\/uploads\/2021\/11\/image1.png","width":1213,"height":492},{"@type":"BreadcrumbList","@id":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/configure-mod-expires-headers\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/"},{"@type":"ListItem","position":2,"name":"How to configure mod_expires headers to manage cache?"}]},{"@type":"WebSite","@id":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/#website","url":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/","name":"Web Hosting FAQs by MilesWeb","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-GB"},{"@type":"Person","@id":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/#\/schema\/person\/e46bb3e1613b47b1975e8635509d1770","name":"Prajakta Marathe","image":{"@type":"ImageObject","inLanguage":"en-GB","@id":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/9dfa3db3773d6f2f050e32c73f20638d?s=96&d=blank&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/9dfa3db3773d6f2f050e32c73f20638d?s=96&d=blank&r=g","caption":"Prajakta Marathe"},"description":"Prajakta is a content writer at MilesWeb. She is ardent about writing technical and non-technical blogs. Adding value to know-how is what she believes in. She also has good experience in educational field. Gratified in sharing knowledge.","url":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/author\/prajakta-marathe\/"}]}},"views":216,"_links":{"self":[{"href":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/wp-json\/wp\/v2\/posts\/12346","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/wp-json\/wp\/v2\/users\/25"}],"replies":[{"embeddable":true,"href":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/wp-json\/wp\/v2\/comments?post=12346"}],"version-history":[{"count":3,"href":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/wp-json\/wp\/v2\/posts\/12346\/revisions"}],"predecessor-version":[{"id":14653,"href":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/wp-json\/wp\/v2\/posts\/12346\/revisions\/14653"}],"wp:attachment":[{"href":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/wp-json\/wp\/v2\/media?parent=12346"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/wp-json\/wp\/v2\/categories?post=12346"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/wp-json\/wp\/v2\/tags?post=12346"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}