Logo Background

Speed Up Blog With Apache .htaccess

  • By on January 19, 2010 | No Comments

    Is it possible to speed up your blog by using Apache .htaccess? There’s truth behind the answer where we have tried to add in certain configuration on .htaccess and the blog speed up more than 2 – 3 times.

    We have tried to test the performance before and after using the Firebug, Page Speed and YSlow tools in Firefox to prove the result.

    You can eventually use the same method to track on the blog performance.

    So what’s the new configuration added in .htaccess? In this part, I focus on the caching and compression setting in the .htaccess file.

    The first section was added to tell the browser to cache the media files in client’s workstation for one month, so that there will be no need to get the same media files from server.

    The second section acts the same except the time for caching was set to expire in 7 days.

    # Turn on Expires and set default expires to 3 month
    ExpiresActive On
    ExpiresDefault A7257600
    ExpiresByType image/x-icon A14515200
     
    # Set up caching on media files for 1 month
    <FilesMatch "\.(gif|jpg|JPG|jpeg|png|PNG)$">
      ExpiresDefault A2419200
    </FilesMatch>
     
    # Set up caching on commonly updated files 1 month
    <FilesMatch "\.(xml|txt|html|js|css)$">
      ExpiresDefault A2419200
    </FilesMatch>
     
    <FilesMatch "\.(ico|gif|jpg|JPG|jpeg|png|PNG|css|js|html?|xml|txt)$">
    FileETag None
    </FilesMatch>
     
    <IfModule mod_deflate.c>
    <FilesMatch "\.(js|css)$">
    SetOutputFilter DEFLATE
    </FilesMatch>
    </IfModule>

    The final section on the mod deflate is the best optimization where all the .js and .css files will be compress by the Apache server before serve it to the client.

    However, some old browser doesn’t support the gzip decompression and your blog will load partially as the result.

    Overall it boost the blog speed to 2 – 3 times faster and I hope the sharing of this configuration technique will benefit your site as well.

    Previous
    Next
    » Monitor Unix Memory RSS And VSS
Leave a Comment