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

Discussion regarding Joomla! 1.5 Performance issues.

Moderator: General Support Moderators

Forum rules
Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting, this means YOU.
Security and Performance FAQs
Forum Post Assistant - If you are serious about wanting help, you will use this tool to help you post.
Locked
myaviation
Joomla! Explorer
Joomla! Explorer
Posts: 335
Joined: Thu Nov 27, 2008 8:18 pm

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

Post by myaviation » Tue Aug 03, 2010 6:53 pm

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

User avatar
stutteringp0et
Joomla! Ace
Joomla! Ace
Posts: 1382
Joined: Sat Oct 28, 2006 11:16 pm
Location: Texas
Contact:

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

Post by stutteringp0et » Tue Aug 03, 2010 7:04 pm

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.
My extensions: http://extensions.joomla.org/profile/pr ... ails/18398
Honk if this signature offends you.

myaviation
Joomla! Explorer
Joomla! Explorer
Posts: 335
Joined: Thu Nov 27, 2008 8:18 pm

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

Post by myaviation » Tue Aug 03, 2010 7:12 pm

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..

User avatar
stutteringp0et
Joomla! Ace
Joomla! Ace
Posts: 1382
Joined: Sat Oct 28, 2006 11:16 pm
Location: Texas
Contact:

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

Post by stutteringp0et » Tue Aug 03, 2010 7:55 pm

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
My extensions: http://extensions.joomla.org/profile/pr ... ails/18398
Honk if this signature offends you.

jenstudio
Joomla! Apprentice
Joomla! Apprentice
Posts: 8
Joined: Tue Jan 25, 2011 11:28 pm

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

Post by jenstudio » Wed Nov 13, 2013 6:42 am

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

yuri1982
Joomla! Apprentice
Joomla! Apprentice
Posts: 9
Joined: Sat Oct 25, 2008 9:05 am
Location: italy

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

Post by yuri1982 » Thu Nov 21, 2013 11:31 am

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 # ???

the apprentice
Joomla! Guru
Joomla! Guru
Posts: 682
Joined: Wed Nov 18, 2009 3:53 pm

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

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

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?


Locked

Return to “Performance - Joomla! 1.5”