View Tutorial Metadata Edit Content Revision History Add New Tutorial Add to Watchlist How to speed up your site using .htaccess

How to speed up your site using .htaccess

In this tutorial you will find out how to speed up your site with only some minor changes to your .htaccess file

Enable file caching

Enable caching of files on the client-side (inside the browser).

Header unset Pragma
FileETag None
Header unset ETag
 
# cache images/pdf docs for 10 days
<FilesMatch "\.(ico|pdf|jpg|jpeg|png|gif)$">
Header set Cache-Control "max-age=864000, public, must-revalidate"
Header unset Last-Modified
</FilesMatch>
 
# cache html/htm/xml/txt diles for 2 days
<FilesMatch "\.(html|htm|xml|txt|xsl)$">
Header set Cache-Control "max-age=7200, must-revalidate"
</FilesMatch>

For more details, see How to enable file caching with .htaccess in Apache

Compress JavaScript and style-sheet files

<IfModule mod_deflate.c>
<FilesMatch "\.(js|css)$">
SetOutputFilter DEFLATE
</FilesMatch>
</IfModule>

Talk icons discuss – in the article above, point your mouse over them to reply.
Can't find a relevant Talk icon for what you have to say? See how you can add one...
Note: All the talks and replies are also listed below.

Created: 2009-08-13 discuss Spilt in two (or more) separate tutorials?
  • dragos (2009-08-13 06:57):
    Hey Sorin, I was wondering if you agree to split this up
    into smaller tutorials, and explain in more details what the
    instructions mean.
  • TrimbitasSorin (2009-08-13 07:06):
    Of course. I'll do this next week :)

Reply

Choose one from the list

Only plain text supported.

Optional

Required - will be kept private

Optional


Please type the security code in the box. To turn it off, you need a Tutorialpedia account.


Add a new discussion topic (Only if you don't find it above, duplicates will be removed)


Rating: (0+, 0-) In: Apache