Proper caching method with .htaccess
        Posted  
        
            by 
                mark075
            
        on Pro Webmasters
        
        See other posts from Pro Webmasters
        
            or by mark075
        
        
        
        Published on 2012-06-07T13:55:57Z
        Indexed on 
            2012/06/07
            16:48 UTC
        
        
        Read the original article
        Hit count: 278
        
htaccess
There are a lot of snippets that enable caching on a website and I don't know which one should I use. The most popular is something like this:
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access 1 year"
ExpiresByType image/png "access 1 year"
ExpiresByType text/css "access 1 month"
ExpiresDefault "access 2 days"
</IfModule>
I also found something similar, but with keyword 'plus'. Like this:
ExpiresByType image/png "access plus 2592000 seconds"
What does it mean, because I didn't find anything in the documentation.
Another snippet I found:
<ifModule mod_headers.c>
  <filesMatch "\.(ico|jpe?g|png|gif|swf)$">
    Header set Cache-Control "max-age=2592000, public"
  </filesMatch>
  <filesMatch "\.(css)$">
    Header set Cache-Control "max-age=604800, public"
  </filesMatch>
  <filesMatch "\.(js)$">
    Header set Cache-Control "max-age=216000, private"
  </filesMatch>
  <filesMatch "\.(x?html?|php)$">
    Header set Cache-Control "max-age=600, private, must-revalidate"
  </filesMatch>
</ifModule>
What is the best practice?
© Pro Webmasters or respective owner