如何通过的Apache2送COM pressed(瘪)SVG? [英] How to send compressed (deflated) SVG via Apache2?
问题描述
我指定我的网站的.htaccess
文件中的以下属性:
AddOutputFilterByType DEFLATE图像/ SVG + XML
DeflateCom pressionLevel 9
头追加因人而异接受编码
不过,我的SVG资产不被发送COM pressed形式:
$卷曲https://example.org/assets/svg/asset.svg --silent -H接受编码:gzip,紧缩--write出$ {size_download} \ N--output的/ dev / null的
152655
$卷曲https://example.org/assets/svg/asset.svg --silent --write出%{size_download} \ N--output的/ dev / null的
152655
我验证了该资产( asset.svg
)被发送MIME类型图像/ SVG + XML
使用铬,但使用Web开发工具,当向客户端发送该特定文件是不是被玉米pressed
添加其他MIME类型为的.htaccess
文件是成功的(例如,添加的text / html
COM presses的HTML资产)。
这似乎是具体到如何SVG数据的处理。我还有什么可以尝试或解决让SVG COM pression工作?
将AddType图像/ SVG + XML .SVG
AddOutputFilterByType DEFLATE图像/ SVG + XML
这两条线解决了这个问题对我来说另一个文件类型。我只是改变了他们SVG(注意。
在 SVG
)
将AddType图像/ SVG + XML的SVG SVGZ
AddEncoding GZIP SVGZ
I have specified the following attributes in my site's .htaccess
file:
AddOutputFilterByType DEFLATE image/svg+xml
DeflateCompressionLevel 9
Header append Vary Accept-Encoding
However, my SVG asset is not being sent in compressed form:
$ curl https://example.org/assets/svg/asset.svg --silent -H "Accept-Encoding: gzip,deflate" --write-out "${size_download}\n" --output /dev/null
152655
$ curl https://example.org/assets/svg/asset.svg --silent --write-out "%{size_download}\n" --output /dev/null
152655
I verified that this asset (asset.svg
) is being sent with MIME type image/svg+xml
using Chrome, but using the Web Developer tools, this specific file is not being compressed when sent to the client.
Adding other MIME types to the .htaccess
file is successful (e.g., adding text/html
compresses the HTML assets).
This seems specific to how SVG data are handled. What else can I try or troubleshoot to get SVG compression working?
AddType image/svg+xml .svg
AddOutputFilterByType DEFLATE image/svg+xml
These two lines solved it for me for another filetype. I just changed them to svg (note the .
before svg
)
Or try the following from http://kaioa.com/node/45
AddType image/svg+xml svg svgz
AddEncoding gzip svgz
这篇关于如何通过的Apache2送COM pressed(瘪)SVG?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!