Bri*_*nga 8 svg http-compression azure
我正在尝试使用web.config转换在Azure网站中为SVG启用GZip压缩,但没有成功.这是我的变换的样子:
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<system.webServer>
<httpCompression>
<staticTypes>
<add mimeType="image/svg+xml" enabled="true" xdt:Transform="Insert" />
</staticTypes>
</httpCompression>
<staticContent xdt:Transform="Insert">
<mimeMap fileExtension=".svg" mimeType="image/svg+xml" />
</staticContent>
</system.webServer>
</configuration>
Run Code Online (Sandbox Code Playgroud)
这应该都为SVG添加mime类型,Azure似乎没有,然后启用压缩.我已经验证了mime类型添加工作正常,但在发布时我得到压缩元素的错误:
源文档中的任何元素都不匹配'/configuration/system.webServer/httpCompression/staticTypes'
从转换中删除压缩并将其直接添加到我的web.config文件中会删除错误,但我仍然没有在HTTP标头中看到压缩.以下是响应标头:
Accept-Ranges:bytes
Content-Length:23265
Content-Type:image/svg+xml
Date:Mon, 10 Jun 2013 17:19:37 GMT
ETag:"c4e9ec93d765ce1:0"
Last-Modified:Mon, 10 Jun 2013 12:39:41 GMT
Server:Microsoft-IIS/8.0
X-Powered-By:ASP.NET
X-Powered-By:ARR/2.5
X-Powered-By:ASP.NET
Run Code Online (Sandbox Code Playgroud)
以下是在 web.config 中启用它的方法:
<configuration>
<system.webServer>
<staticContent>
<mimeMap fileExtension=".svg" mimeType="image/svg+xml" />
</staticContent>
<httpCompression>
<staticTypes>
<remove mimeType="*/*" />
<add mimeType="image/svg+xml" enabled="true" />
<add mimeType="*/*" enabled="false" />
</staticTypes>
</httpCompression>
</system.webServer>
</configuration>
Run Code Online (Sandbox Code Playgroud)
关键是删除了所有内容(然后重新添加)。如果你没有那个,那么 svg 行基本上会被忽略,因为 catch-all 是从 applicationhost.config 继承的,并且在它到达 svg 行之前捕获所有。
| 归档时间: |
|
| 查看次数: |
3943 次 |
| 最近记录: |