.htaccess - Gzip works but browser caching does not -
i've looked on several stackoverflow questions , tried solutions none of them worked me.
i got huge .htaccess right now, got answer lot of votes tried lot of others too. gzip compression works still "leverage browser caching" in pagespeed.
# leverage browser caching <ifmodule mod_expires.c> expiresactive on expiresbytype image/jpg "access 1 year" expiresbytype image/jpeg "access 1 year" expiresbytype image/gif "access 1 year" expiresbytype image/png "access 1 year" expiresbytype text/css "access 1 month" expiresbytype text/html "access 1 month" expiresbytype application/pdf "access 1 month" expiresbytype text/x-javascript "access 1 month" expiresbytype application/x-shockwave-flash "access 1 month" expiresbytype image/x-icon "access 1 year" expiresdefault "access 1 month" </ifmodule> <ifmodule mod_headers.c> <filesmatch "\.(ico|flv|jpg|jpeg|png|gif|css|swf)$"> header set cache-control "max-age=2678400, public" </filesmatch> <filesmatch "\.(html|htm)$"> header set cache-control "max-age=7200, private, must-revalidate" </filesmatch> <filesmatch "\.(pdf)$"> header set cache-control "max-age=86400, public" </filesmatch> <filesmatch "\.(js)$"> header set cache-control "max-age=2678400, private" </filesmatch> </ifmodule> # enable compression <ifmodule mod_deflate.c> addoutputfilterbytype deflate application/javascript addoutputfilterbytype deflate application/rss+xml addoutputfilterbytype deflate application/vnd.ms-fontobject addoutputfilterbytype deflate application/x-font addoutputfilterbytype deflate application/x-font-opentype addoutputfilterbytype deflate application/x-font-otf addoutputfilterbytype deflate application/x-font-truetype addoutputfilterbytype deflate application/x-font-ttf addoutputfilterbytype deflate application/x-javascript addoutputfilterbytype deflate application/xhtml+xml addoutputfilterbytype deflate application/xml addoutputfilterbytype deflate font/opentype addoutputfilterbytype deflate font/otf addoutputfilterbytype deflate font/ttf addoutputfilterbytype deflate image/svg+xml addoutputfilterbytype deflate image/x-icon addoutputfilterbytype deflate text/css addoutputfilterbytype deflate text/html addoutputfilterbytype deflate text/javascript addoutputfilterbytype deflate text/plain </ifmodule> <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>
Comments
Post a Comment