Enable compression and caching of SVG files in .htaccess file -
when analyze website google pagespeed insight, should fix problems regarding compression of svg files.
i've been looking around web trying find solution on problem, no matter doesn't seem work, therefor i'm asking guys.
i've checked if gzip enabled through multiple tools on web, , seem true.
so far got in .htaccess file.
rewriteengine on options followsymlinks rewritebase / rewritecond %{request_filename} !-d rewritecond %{request_filename} !-f rewriterule ^(.*)$ /#/$1 [l] addtype image/svg+xml svg svgz addencoding gzip svgz ## expires caching ## <ifmodule mod_expires.c> expiresactive on expiresbytype image/jpg "access 1 month" expiresbytype image/jpeg "access 1 month" expiresbytype image/gif "access 1 month" expiresbytype image/png "access 1 month" expiresbytype text/css "access 1 week" expiresbytype text/html "access 1 day" expiresbytype application/pdf "access 1 month" expiresbytype text/x-javascript "access 1 month" expiresbytype image/x-icon "access 1 month" expiresbytype image/svg "access 1 month" expiresdefault "access 1 month" </ifmodule> ## expires caching ## ## file compression ## <ifmodule mod_gzip.c> mod_gzip_on yes mod_gzip_dechunk yes mod_gzip_item_include file .(html?|txt|css|js|svg|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_include mime ^image/svg+xml.* mod_gzip_item_exclude rspheader ^content-encoding:.*gzip.* </ifmodule> ## file compression ## # mod_deflate configuration <ifmodule mod_deflate.c> # restrict compression these mime types addoutputfilterbytype deflate text/plain addoutputfilterbytype deflate text/html addoutputfilterbytype deflate application/xhtml+xml addoutputfilterbytype deflate text/xml addoutputfilterbytype deflate application/xml addoutputfilterbytype deflate application/xml+rss addoutputfilterbytype deflate application/x-javascript addoutputfilterbytype deflate text/javascript addoutputfilterbytype deflate text/css addoutputfilterbytype deflate image/svg addoutputfilterbytype deflate image/svg+xml <ifmodule mod_headers.c> # make sure proxies don't deliver wrong content header append vary user-agent env=!dont-vary </ifmodule>
i hope come solution problem since i've tried myself several hours.
browser caching doesn't work svg neither. maybe there similar problem?
very late response seeking same myself today.
the correct expires header line be:
expiresbytype image/svg+xml "access 1 month"
likewise image/svg+xml can used gzip declarations.
Comments
Post a Comment