Can someone provide me with an optimized .htaccess configuration that handles compression, browser caching, proxy caching, etc. for a typical website?
Aside from my visitors, I'm also trying to make Google PageSpeed happy. I wanna use caching and gzip compression through .htaccess please help me with its code!
I want to cache icon,pdf,flv,jpg,png,gif,js,css,swf
files for long time
I want to cache xml,txt
files for 2 Days
I want to cache html
files for 2 Days
And I wanna compress my html,txt,css,js,php
files because those have large file size.
Is there any way to gzip images using .htaccess?
# 480 weeks <FilesMatch "\.(ico|pdf|flv|jpg|jpeg|png|gif|js|css|swf)$"> Header set Cache-Control "max-age=290304000, public" </FilesMatch> # 2 DAYS <FilesMatch "\.(xml|txt)$"> Header set Cache-Control "max-age=172800, public, must-revalidate" </FilesMatch> # 2 HOURS <FilesMatch "\.(html|htm)$"> Header set Cache-Control "max-age=7200, must-revalidate" </FilesMatch> <ifModule mod_gzip.c> mod_gzip_on Yes mod_gzip_dechunk Yes mod_gzip_item_include file \.(html?|txt|css|js|php|pl)$ mod_gzip_item_include handler ^cgi-script$ mod_gzip_item_include mime ^text/.* mod_gzip_item_include mime ^application/x-javascript.* mod_gzip_item_exclude mime ^image/.* mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.* </ifModule>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With