{"id":8970,"date":"2020-01-29T10:15:48","date_gmt":"2020-01-29T10:15:48","guid":{"rendered":"https:\/\/www.milesweb.in\/hosting-faqs\/?p=8970"},"modified":"2023-01-27T19:30:57","modified_gmt":"2023-01-27T14:00:57","slug":"learn-to-configure-caching-with-the-mod-expires-module","status":"publish","type":"post","link":"https:\/\/www.milesweb.in\/hosting-faqs\/learn-to-configure-caching-with-the-mod-expires-module\/","title":{"rendered":"Learn to configure caching with the mod_expires module"},"content":{"rendered":"<p>This article covers the introduction to Apache&#8217;s document expiration functionality provided by the mod_expires module.<\/p>\n<p>By setting up the expiration periods for web content allows your web browser to cache the content for a specific time period. Therefore, it allows you to reduce the number of HTTP requests that the web server must process, which helps in improving web site speed and performance.<\/p>\n<h3># How to use the mod_expires module?<\/h3>\n<p>Using Apache&#8217;s mod_expires module you can define expiration intervals for different types of content on your website. For example, it allows you to use mod_expires directives to instruct browsers to cache image files for one hour, or JavaScript files for two weeks and also CSS files for two months.<\/p>\n<p>Following is the sample .htaccess configuration that shows how to do it :<\/p>\n<pre class=\"trim-whitespace:false lang:default decode:true \">ExpiresActive On\nExpiresByType image\/png \"access 2 hour\"\nExpiresByType image\/gif \"access 2 hour\"\nExpiresByType image\/jpeg \"access 2 hour\"\nExpiresByType text\/javascript \"access 2 weeks\"\nExpiresByType text\/css \"access 2 months\"\nExpiresByType text\/html \"modification 4 hours\"\nExpiresDefault \"access 2 days\"<\/pre>\n<p>In the above example :<\/p>\n<p>\u2022 You can see that the <strong>ExpiresActive<\/strong> directive is set to On. This instructs Apache to generate Expires and Cache-Control HTTP response headers for the specific content types. Web browsers than resolve these HTTP response headers to determine how long to cache content on the client.<\/p>\n<p>\u2022 The <strong>ExpiresByType<\/strong> directive denotes the expiration periods for the specific types of content. You are allowed to specify the expiration time in seconds, minutes, hours, days, weeks, months and also in years. In order to define a specific type of content, use the MIME type, like text\/html or image\/png. You can find more MIME types here <a href=\"https:\/\/en.wikipedia.org\/wiki\/Media_type\" target=\"_blank\" rel=\"noopener nofollow\">https:\/\/en.wikipedia.org\/wiki\/Media_type<\/a>.<\/p>\n<p>\u2022 The<strong> ExpiresDefault<\/strong> directive is an optional directive that defines the expiration period of all other types of files and not explicitly set in an <strong>ExpiresByType<\/strong> directive. In this example, any file which is not an image, JavaScript or CSS file gets expire in two days.<\/p>\n<div style=\"background-color: #e0ffff; padding: 10px;\"><strong>Note:<\/strong> You can if verify your expiration settings in the .htaccess file are working correctly or not, by examining the raw HTTP headers that are sent between the browser and web server.<br \/>\n(To perform this, use a browser plugin that is able to display the raw headers like Live HTTP headers for Mozilla Firefox, or the Developer Tools feature in Google Chrome). When the content gets marked for expiration, Apache itself adds the following lines to the HTTP response header (the exact values will vary based on your own .htaccess settings):<\/p>\n<p style=\"border: 3px; border-style: solid; border-color: #D3D3D3; padding: 1em;\">Cache-Control: max-age=86400<br \/>\nExpires: Thu, 02 Oct 2014 19:02:30 GMT<\/p>\n<\/div>\n<p><strong>Also Read :<\/strong><\/p>\n<p><strong>1)&nbsp;<\/strong><a href=\"https:\/\/www.milesweb.in\/hosting-faqs\/enable-caching-drupal\/\" target=\"_blank\" rel=\"noopener\"><strong>How To Enable Caching In Drupal?<\/strong><\/a><\/p>\n<p><strong>2)&nbsp;<\/strong><a href=\"https:\/\/www.milesweb.in\/hosting-faqs\/fix-leverage-browser-caching-wordpress-website\/\" target=\"_blank\" rel=\"noopener\"><strong>How To Fix Leverage Browser Caching In WordPress Website<\/strong><\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>This article covers the introduction to Apache&#8217;s document expiration functionality provided by the mod_expires module. By setting up the expiration periods for web content allows your web browser to cache the content for a specific time period. Therefore, it allows you to reduce the number of HTTP requests that the web server must process, which [&hellip;]<\/p>\n","protected":false},"author":18,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[41],"tags":[1261,1260],"class_list":["post-8970","post","type-post","status-publish","format-standard","placeholder-for-hentry","category-howtos","tag-caching-with-mod_expires-moduleremove","tag-mod-expires-module"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.1.1 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Learn to configure caching with the mod_expires module - Web Hosting FAQs by MilesWeb<\/title>\n<meta name=\"description\" content=\"A guide on how to configure caching with the mod_expires module.\" \/>\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.in\/hosting-faqs\/learn-to-configure-caching-with-the-mod-expires-module\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Learn to configure caching with the mod_expires module - Web Hosting FAQs by MilesWeb\" \/>\n<meta property=\"og:description\" content=\"A guide on how to configure caching with the mod_expires module.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.milesweb.in\/hosting-faqs\/learn-to-configure-caching-with-the-mod-expires-module\/\" \/>\n<meta property=\"og:site_name\" content=\"Web Hosting FAQs by MilesWeb\" \/>\n<meta property=\"article:published_time\" content=\"2020-01-29T10:15:48+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-01-27T14:00:57+00:00\" \/>\n<meta name=\"author\" content=\"Sonam Wagh\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Sonam Wagh\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. 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\":\"Article\",\"@id\":\"https:\/\/www.milesweb.in\/hosting-faqs\/learn-to-configure-caching-with-the-mod-expires-module\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.milesweb.in\/hosting-faqs\/learn-to-configure-caching-with-the-mod-expires-module\/\"},\"author\":{\"name\":\"Sonam Wagh\",\"@id\":\"https:\/\/www.milesweb.in\/hosting-faqs\/#\/schema\/person\/dc645d02823c86e07e53798ebe02c6f4\"},\"headline\":\"Learn to configure caching with the mod_expires module\",\"datePublished\":\"2020-01-29T10:15:48+00:00\",\"dateModified\":\"2023-01-27T14:00:57+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.milesweb.in\/hosting-faqs\/learn-to-configure-caching-with-the-mod-expires-module\/\"},\"wordCount\":420,\"commentCount\":0,\"keywords\":[\"caching with mod_expires moduleRemove\",\"mod-expires module\"],\"articleSection\":[\"How-Tos\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.milesweb.in\/hosting-faqs\/learn-to-configure-caching-with-the-mod-expires-module\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.milesweb.in\/hosting-faqs\/learn-to-configure-caching-with-the-mod-expires-module\/\",\"url\":\"https:\/\/www.milesweb.in\/hosting-faqs\/learn-to-configure-caching-with-the-mod-expires-module\/\",\"name\":\"Learn to configure caching with the mod_expires module - Web Hosting FAQs by MilesWeb\",\"isPartOf\":{\"@id\":\"https:\/\/www.milesweb.in\/hosting-faqs\/#website\"},\"datePublished\":\"2020-01-29T10:15:48+00:00\",\"dateModified\":\"2023-01-27T14:00:57+00:00\",\"author\":{\"@id\":\"https:\/\/www.milesweb.in\/hosting-faqs\/#\/schema\/person\/dc645d02823c86e07e53798ebe02c6f4\"},\"description\":\"A guide on how to configure caching with the mod_expires module.\",\"breadcrumb\":{\"@id\":\"https:\/\/www.milesweb.in\/hosting-faqs\/learn-to-configure-caching-with-the-mod-expires-module\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.milesweb.in\/hosting-faqs\/learn-to-configure-caching-with-the-mod-expires-module\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.milesweb.in\/hosting-faqs\/learn-to-configure-caching-with-the-mod-expires-module\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.milesweb.in\/hosting-faqs\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Learn to configure caching with the mod_expires module\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.milesweb.in\/hosting-faqs\/#website\",\"url\":\"https:\/\/www.milesweb.in\/hosting-faqs\/\",\"name\":\"Web Hosting FAQs by MilesWeb\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.milesweb.in\/hosting-faqs\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.milesweb.in\/hosting-faqs\/#\/schema\/person\/dc645d02823c86e07e53798ebe02c6f4\",\"name\":\"Sonam Wagh\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.milesweb.in\/hosting-faqs\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/www.milesweb.in\/hosting-faqs\/wp-content\/uploads\/2019\/12\/Sonam-Wagh-150x150.jpg\",\"contentUrl\":\"https:\/\/www.milesweb.in\/hosting-faqs\/wp-content\/uploads\/2019\/12\/Sonam-Wagh-150x150.jpg\",\"caption\":\"Sonam Wagh\"},\"description\":\"With an interest in doing something creative daily, Sonam works as a Digital Marketing Executive. She likes to write technical blogs related to web hosting, digital marketing, and other IT topics. She also likes to spend her leisure time on social media to find different strategies for client engagement.\",\"url\":\"https:\/\/www.milesweb.in\/hosting-faqs\/author\/sonam\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Learn to configure caching with the mod_expires module - Web Hosting FAQs by MilesWeb","description":"A guide on how to configure caching with the mod_expires module.","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.in\/hosting-faqs\/learn-to-configure-caching-with-the-mod-expires-module\/","og_locale":"en_US","og_type":"article","og_title":"Learn to configure caching with the mod_expires module - Web Hosting FAQs by MilesWeb","og_description":"A guide on how to configure caching with the mod_expires module.","og_url":"https:\/\/www.milesweb.in\/hosting-faqs\/learn-to-configure-caching-with-the-mod-expires-module\/","og_site_name":"Web Hosting FAQs by MilesWeb","article_published_time":"2020-01-29T10:15:48+00:00","article_modified_time":"2023-01-27T14:00:57+00:00","author":"Sonam Wagh","twitter_misc":{"Written by":"Sonam Wagh","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.milesweb.in\/hosting-faqs\/learn-to-configure-caching-with-the-mod-expires-module\/#article","isPartOf":{"@id":"https:\/\/www.milesweb.in\/hosting-faqs\/learn-to-configure-caching-with-the-mod-expires-module\/"},"author":{"name":"Sonam Wagh","@id":"https:\/\/www.milesweb.in\/hosting-faqs\/#\/schema\/person\/dc645d02823c86e07e53798ebe02c6f4"},"headline":"Learn to configure caching with the mod_expires module","datePublished":"2020-01-29T10:15:48+00:00","dateModified":"2023-01-27T14:00:57+00:00","mainEntityOfPage":{"@id":"https:\/\/www.milesweb.in\/hosting-faqs\/learn-to-configure-caching-with-the-mod-expires-module\/"},"wordCount":420,"commentCount":0,"keywords":["caching with mod_expires moduleRemove","mod-expires module"],"articleSection":["How-Tos"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.milesweb.in\/hosting-faqs\/learn-to-configure-caching-with-the-mod-expires-module\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.milesweb.in\/hosting-faqs\/learn-to-configure-caching-with-the-mod-expires-module\/","url":"https:\/\/www.milesweb.in\/hosting-faqs\/learn-to-configure-caching-with-the-mod-expires-module\/","name":"Learn to configure caching with the mod_expires module - Web Hosting FAQs by MilesWeb","isPartOf":{"@id":"https:\/\/www.milesweb.in\/hosting-faqs\/#website"},"datePublished":"2020-01-29T10:15:48+00:00","dateModified":"2023-01-27T14:00:57+00:00","author":{"@id":"https:\/\/www.milesweb.in\/hosting-faqs\/#\/schema\/person\/dc645d02823c86e07e53798ebe02c6f4"},"description":"A guide on how to configure caching with the mod_expires module.","breadcrumb":{"@id":"https:\/\/www.milesweb.in\/hosting-faqs\/learn-to-configure-caching-with-the-mod-expires-module\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.milesweb.in\/hosting-faqs\/learn-to-configure-caching-with-the-mod-expires-module\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.milesweb.in\/hosting-faqs\/learn-to-configure-caching-with-the-mod-expires-module\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.milesweb.in\/hosting-faqs\/"},{"@type":"ListItem","position":2,"name":"Learn to configure caching with the mod_expires module"}]},{"@type":"WebSite","@id":"https:\/\/www.milesweb.in\/hosting-faqs\/#website","url":"https:\/\/www.milesweb.in\/hosting-faqs\/","name":"Web Hosting FAQs by MilesWeb","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.milesweb.in\/hosting-faqs\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.milesweb.in\/hosting-faqs\/#\/schema\/person\/dc645d02823c86e07e53798ebe02c6f4","name":"Sonam Wagh","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.milesweb.in\/hosting-faqs\/#\/schema\/person\/image\/","url":"https:\/\/www.milesweb.in\/hosting-faqs\/wp-content\/uploads\/2019\/12\/Sonam-Wagh-150x150.jpg","contentUrl":"https:\/\/www.milesweb.in\/hosting-faqs\/wp-content\/uploads\/2019\/12\/Sonam-Wagh-150x150.jpg","caption":"Sonam Wagh"},"description":"With an interest in doing something creative daily, Sonam works as a Digital Marketing Executive. She likes to write technical blogs related to web hosting, digital marketing, and other IT topics. She also likes to spend her leisure time on social media to find different strategies for client engagement.","url":"https:\/\/www.milesweb.in\/hosting-faqs\/author\/sonam\/"}]}},"_links":{"self":[{"href":"https:\/\/www.milesweb.in\/hosting-faqs\/wp-json\/wp\/v2\/posts\/8970","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.milesweb.in\/hosting-faqs\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.milesweb.in\/hosting-faqs\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.milesweb.in\/hosting-faqs\/wp-json\/wp\/v2\/users\/18"}],"replies":[{"embeddable":true,"href":"https:\/\/www.milesweb.in\/hosting-faqs\/wp-json\/wp\/v2\/comments?post=8970"}],"version-history":[{"count":4,"href":"https:\/\/www.milesweb.in\/hosting-faqs\/wp-json\/wp\/v2\/posts\/8970\/revisions"}],"predecessor-version":[{"id":17412,"href":"https:\/\/www.milesweb.in\/hosting-faqs\/wp-json\/wp\/v2\/posts\/8970\/revisions\/17412"}],"wp:attachment":[{"href":"https:\/\/www.milesweb.in\/hosting-faqs\/wp-json\/wp\/v2\/media?parent=8970"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.milesweb.in\/hosting-faqs\/wp-json\/wp\/v2\/categories?post=8970"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.milesweb.in\/hosting-faqs\/wp-json\/wp\/v2\/tags?post=8970"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}