Add expiring header without mod_expires?

I know that I can add the expires header using mod_expires. However, what can I do if mod_expires is not installed on the Apache server and I do not want to direct access to files using a scripting language such as PHP?

+6
apache .htaccess mod-expires
source share
3 answers

You can use mod_header to set the header field manually:

Header set Expires "..." 

But since Expires requires absolute time , use the max-age Cache-Control parameter for time relative to access time:

 Header merge Cache-Control max-age=3600 
+6
source share

If you have Expires static headers, the following will add the Expires header to your js and css files:

 <FilesMatch "\.(js|css)$"> Header set Expires "Fri, 01 Jan 2010 00:00:00 GMT" </FilesMatch> 
+1
source share

This means that the browser should refresh the page on subsequent visits. The expiration date should only be in the past ... you could set the date using PHP to make it "fair" in the past or just leave it as the date you found this answer !!!

 header("Cache-Control: no-cache, must-revalidate"); header("Expires: Thu, 2 Sep 2010 05:00:00 GMT"); 

UPDATE: Apologies. I missed the "Do Not" in the sentence about routing files through PHP! You can also use these HTML meta tags:

 <meta http-equiv="Cache-Control" content="no-cache"> <meta http-equiv="Pragma" content="no-cache"> <meta http-equiv="expires" content="Thu, 2 Sep 2010 05:00:00 GMT"> 
+1
source share

All Articles