如何通过的Apache2送COM pressed(瘪)SVG? [英] How to send compressed (deflated) SVG via Apache2?

查看:214
本文介绍了如何通过的Apache2送COM pressed(瘪)SVG?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我指定我的网站的.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

或尝试从 http://kaioa.com/node/45

以下

 将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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆