{"id":1587,"date":"2010-09-13T15:08:20","date_gmt":"2010-09-13T09:38:20","guid":{"rendered":"http:\/\/www.tothenew.com\/blog\/?p=1587"},"modified":"2016-12-19T15:06:26","modified_gmt":"2016-12-19T09:36:26","slug":"setting-expires-http-header-on-server-response-through-apache","status":"publish","type":"post","link":"https:\/\/www.tothenew.com\/blog\/setting-expires-http-header-on-server-response-through-apache\/","title":{"rendered":"Setting Expires HTTP header on server response through Apache"},"content":{"rendered":"<p>In recent poc, i have set the expires HTTP header on server response for one of the project, such that it will again set when access by user for the specified period, if header is expired already.<br \/>\nThe module that control it is <strong>&#8220;mod_expires.c&#8221;<\/strong>. This module is not enabled by default.<br \/>\nYou need to enable it by following command (You need to be sudo user):<\/p>\n<pre lang=\"groovy\">a2enmod {module name} \/\/here module name is \"expires\"<\/pre>\n<p>Then, open your site configuration file available at apache2\/sites-available\/{your site}<br \/>\n<\/p>\n<p>Append following xml entries in your site configuration file :<\/p>\n<pre lang=\"groovy\">\r\n<IfModule mod_expires.c>\r\n      <FilesMatch \"\\.(ico|pdf|flv|jpg|jpeg|png|gif|js|css|swf)$\">\r\n          ExpiresActive On\r\n          ExpiresDefault \"access plus 2 days\"\r\n      <\/FilesMatch>\r\n<\/IfModule>\r\n<\/pre>\n<p>ExpiresDefault Syntax :<\/p>\n<pre lang=\"groovy\">ExpiresDefault \"{base} [plus] {num  type}*\"<\/pre>\n<p><strong>Note :<\/strong> Here base is : &#8216;access&#8217; and the type is : &#8216;years&#8217;, &#8216;months&#8217;, &#8216;weeks&#8217;, &#8216;days&#8217;, &#8216;hours&#8217;, &#8216;minutes&#8217;, &#8216;seconds&#8217;<br \/>\n<\/p>\n<p>You can also use &#8220;ExpiresByType&#8221; for setting different expires for different file type instead of &#8220;ExpiresDefault&#8221;.<br \/>\nHope this code will help \ud83d\ude42<br \/>\n<br \/>\nRegards,<br \/>\nTarun Pareek<br \/>\nIntelligrape Software<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In recent poc, i have set the expires HTTP header on server response for one of the project, such that it will again set when access by user for the specified period, if header is expired already. The module that control it is &#8220;mod_expires.c&#8221;. This module is not enabled by default. You need to enable [&hellip;]<\/p>\n","protected":false},"author":20,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"iawp_total_views":5},"categories":[1],"tags":[18,389,391,390],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/1587"}],"collection":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/users\/20"}],"replies":[{"embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/comments?post=1587"}],"version-history":[{"count":0,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/1587\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/media?parent=1587"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/categories?post=1587"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/tags?post=1587"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}