View Tutorial Metadata Edit Content Revision History Add to Watchlist Add New Tutorial 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>

Only plain text supported.

Optional

Required - will be kept private

Optional

 
 

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