Page 1 of 1

Expire headers Code for .htaccess file is it save check code

Posted: Tue Aug 03, 2010 6:53 pm
by myaviation
i got this code from a user that help with Expire headers - they said to put this in the .htaccess file..

When you put it on your page.. You do notice the YSLOW in firefox - get a BETTER GRADE.. Does this code do anything to your website? Is it safe to run ( just making sure.. I trust the user but never seen this before)

Thanks

Code: Select all

###activate mod_deflate
SetOutputFilter DEFLATE

# Add caching headers for all files
<IfModule mod_expires.c>
   ExpiresActive On

   <FilesMatch \.css$>
      ExpiresDefault "access plus 7 days"
   </FilesMatch>
   ExpiresByType text/css "access plus 7 days"

   <FilesMatch \.js$>
           ExpiresDefault "access plus 7 days"
   </FilesMatch>
   ExpiresByType text/javascript "access plus 7 days"
   ExpiresByType application/javascript "access plus 7 days"
   ExpiresByType application/x-javascript "access plus 7 days"
   ExpiresByType text/x-js "access plus 7 days"
   ExpiresByType text/ecmascript "access plus 7 days"
   ExpiresByType application/ecmascript "access plus 7 days"
   ExpiresByType text/vbscript "access plus 7 days"
   ExpiresByType text/fluffscript "access plus 7 days"

   <FilesMatch \.(bmp|png|gif|jpe?g|ico)$>
           ExpiresDefault "access plus 7 days"
   </FilesMatch>
   ExpiresByType image/gif "access plus 7 days"
   ExpiresByType image/png "access plus 7 days"
   ExpiresByType image/jpeg "access plus 7 days"
   ExpiresByType image/x-icon "access plus 7 days"
   ExpiresByType image/bmp "access plus 7 days"

   <FilesMatch \.(eot|ttf|otf|svg)$>
           ExpiresDefault "access plus 7 days"
   </FilesMatch>
   ExpiresByType application/x-font-opentype "access plus 7 days"
   ExpiresByType application/x-font-truetype "access plus 7 days"
   ExpiresByType application/x-font-ttf "access plus 7 days"
   ExpiresByType application/x-font "access plus 7 days"
   ExpiresByType font/opentype "access plus 7 days"
   ExpiresByType font/otf "access plus 7 days"
   ExpiresByType application/vnd.oasis.opendocument.formula-template "access plus 7 days"
   ExpiresByType image/svg+xml "access plus 7 days"
   ExpiresByType application/vnd.ms-fontobject "access plus 7 days"
   ExpiresByType font/woff "access plus 7 days"

   <FilesMatch \.(flv|wmv|asf|asx|wma|wax|wmx|wm)$>
           ExpiresDefault "access plus 7 days"
   </FilesMatch>
   ExpiresByType video/x-flv "access plus 7 days"
   ExpiresByType video/x-ms-wmv "access plus 7 days"
   ExpiresByType video/x-ms-asf "access plus 7 days"
   ExpiresByType video/x-ms-asx "access plus 7 days"
   ExpiresByType video/x-ms-wma "access plus 7 days"
   ExpiresByType video/x-ms-wax "access plus 7 days"
   ExpiresByType video/x-ms-wmx "access plus 7 days"
   ExpiresByType video/x-ms-wm "access plus 7 days"

   <FilesMatch \.(swf|pdf|doc|rtf|xls|ppt)$>
           ExpiresDefault "access plus 7 days"
   </FilesMatch>
   ExpiresByType application/x-shockwave-flash "access plus 7 days"
   ExpiresByType application/pdf "access plus 7 days"
   ExpiresByType application/msword "access plus 7 days"
   ExpiresByType application/rtf "access plus 7 days"
   ExpiresByType application/vnd.ms-excel "access plus 7 days"
   ExpiresByType application/vnd.ms-powerpoint "access plus 7 days"
</IfModule>
FileETag none

Re: Expire headers Code for .htaccess file is it save check

Posted: Tue Aug 03, 2010 7:04 pm
by stutteringp0et
That looks safe to me.

If you update any files with those file extensions, search engines and returning users will see the old version for up to 7 days.

Your .htaccess doesn't do anything to add expires headers to your html output though.

Re: Expire headers Code for .htaccess file is it save check

Posted: Tue Aug 03, 2010 7:12 pm
by myaviation
Ok thanks I just found if you do a YSLOW on your joomla site. it ranks pretty low.. for the Expire headers..

Do you know of a way with out running this to help the performance..

Re: Expire headers Code for .htaccess file is it save check

Posted: Tue Aug 03, 2010 7:55 pm
by stutteringp0et
nope, that's the way to do it.

You could, however, condense that down to just a few lines. Since they all expire in 7 days, why not do them all at once:

Code: Select all

<IfModule mod_expires.c>
   ExpiresActive On
   <FilesMatch \.(css|js|bmp|png|gif|jpe?g|ico|eot|ttf|otf|svg|flv|wmv|asf|asx|wma|wax|wmx|wm|swf|pdf|doc|rtf|xls|ppt)$>
      ExpiresDefault "access plus 7 days"
   </FilesMatch>
</IfModule>
FileETag none

Re: Expire headers Code for .htaccess file is it save check

Posted: Wed Nov 13, 2013 6:42 am
by jenstudio
Hi Stut,
I used your code above and it has improved performance drastically with PageSpeed being an A- but YSlow still gives me a fail for cache expiration? I get the the following message:

There are 37 static components without a far-future expiration date
http://www.parts-for-cars.com.au/compon ... te-ltr.css
http://www.parts-for-cars.com.au/module ... slider.css
http://www.parts-for-cars.com.au/module ... e/pure.css

etc

why is this still failing YSlow

Re: Expire headers Code for .htaccess file is it save check

Posted: Thu Nov 21, 2013 11:31 am
by yuri1982
stutteringp0et wrote:nope, that's the way to do it.

You could, however, condense that down to just a few lines. Since they all expire in 7 days, why not do them all at once:

Code: Select all

<IfModule mod_expires.c>
   ExpiresActive On
   <FilesMatch \.(css|js|bmp|png|gif|jpe?g|ico|eot|ttf|otf|svg|flv|wmv|asf|asx|wma|wax|wmx|wm|swf|pdf|doc|rtf|xls|ppt)$>
      ExpiresDefault "access plus 7 days"
   </FilesMatch>
</IfModule>
FileETag none

That code must put whit out # ???

Re: Expire headers Code for .htaccess file is it save check

Posted: Thu Nov 26, 2015 7:42 am
by the apprentice

Code: Select all

<IfModule mod_expires.c>
   ExpiresActive On
   <FilesMatch \.(css|js|bmp|png|gif|jpe?g|ico|eot|ttf|otf|svg|flv|wmv|asf|asx|wma|wax|wmx|wm|swf|pdf|doc|rtf|xls|ppt)$>
      ExpiresDefault "access plus 7 days"
   </FilesMatch>
</IfModule>
FileETag none

That code must put whit out # ???[/quote]

Does this quote go anywhere in the htaccess or somewhere specific?