Speed Up Your WordPress Site: Enable gzip and Browser Caching

Speed Up Your WordPress Site: Enable gzip and Browser Caching

in .htaccess
# BEGIN Deflate
<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE text/text text/html text/plain text/xml text/css application/x-javascript application/javascript

# END Deflate

# BEGIN Expires

<IfModule mod_expires.c>

# Enable expirations
ExpiresActive On

# Default directive
ExpiresDefault “access plus 1 month”

# My favicon
ExpiresByType image/x-icon “access plus 1 year”

# Images
ExpiresByType image/gif “access plus 1 month”
ExpiresByType image/png “access plus 1 month”
ExpiresByType image/jpg “access plus 1 month”
ExpiresByType image/jpeg “access plus 1 month”

ExpiresByType text/css “access 1 month”

# Javascript
ExpiresByType application/javascript “access plus 1 year”

ExpiresByType application/pdf “access 1 month”


# END Expires

This code will enable gzip compression for text, HTML, XML, javascript, and CSS files. It will also leverage browser caching for images, CSS, javascript, and PDFs. I recommend running Google’s analysis on your site to see your starting point, then adding the code, supra, to your .htaccess file (if you don’t have an .htaccess file, just create a text file with that name [period included] in your web root), and finally re-running Google’s analysis to see how much you improved. You might just be surprised at how much of a difference a little .htaccess code makes.

Feel free to post in the comments about your before and after results.

Leave a Reply

Your email address will not be published. Required fields are marked *

Previous Post

Useful Tools in internet that i am using

Next Post

Some blogging tips what i read so far

Related Posts