When the two modules namely “mod_expires” and “mod_headers” has been enabled in the server, you can increase the access speed of your website by entering the following in your .htaccess.

=====================
 # BEGIN Compress text files


SetOutputFilter DEFLATE


# END Compress text files

# BEGIN Expire headers

ExpiresActive On
ExpiresDefault “access plus 1 seconds”
ExpiresByType image/x-icon “access plus 2592000 seconds”
ExpiresByType image/jpeg “access plus 2592000 seconds”
ExpiresByType image/png “access plus 2592000 seconds”
ExpiresByType image/gif “access plus 2592000 seconds”
ExpiresByType application/x-shockwave-flash “access plus 2592000 seconds”
ExpiresByType text/css “access plus 604800 seconds”
ExpiresByType text/javascript “access plus 216000 seconds”
ExpiresByType application/javascript “access plus 216000 seconds”
ExpiresByType application/x-javascript “access plus 216000 seconds”
ExpiresByType text/html “access plus 600 seconds”
ExpiresByType application/xhtml+xml “access plus 600 seconds”

# END Expire headers

# BEGIN Cache-Control Headers


Header set Cache-Control “max-age=2592000, public”


Header set Cache-Control “max-age=604800, public”


Header set Cache-Control “max-age=216000, private”


Header set Cache-Control “max-age=600, private, must-revalidate”


# END Cache-Control Headers

# BEGIN Turn ETags Off

Header unset ETag

FileETag None
# END Turn ETags Off

# BEGIN Remove Last-Modified Header

Header unset Last-Modified

# END Remove Last-Modified Header
=====================

Have a Great Surfing by enabling this 🙂 🙂 :) 

4 thoughts on “Increase the access Speed of the site using .htaccess Cache”

  1. Hi,

    Thanks for sharing.

    Actually i am not a technical person but i want to increase the speed of my website so i sent this code to my technical team and i got a reply that you are using windows hosting service and this code will run only those website who are hosted on Linux server.

    is it correct? Please let me know.

  2. Yes, Exactly.

    The windows server cannot recognize the .htaccess file. This is a perfect script that runs over the linux servers which enhance the website speed.

    If you like to increase the website speed in windows server, you can download and install the CloudFlare in the server which can improve the domain speed via temporary cache method.

    Kindly have the URL mentioned below to know about the cloulFlare

    https://www.cloudflare.com/

  3. This is something which is of use for everyone. This post tells you how you can increase access speed of your site using .htaccess. This is one of the easiest ways to do that thing. Thanks for explaining this method to all of us.

Leave a Reply