响应未压缩

时间:2018-11-20 14:29:32

标签: .net-core compression gzip middleware

我有一个网站,我想在其中压缩大型svg图标spritesheet。在startup.cs中,我的ConifgureServices方法中包含以下内容

services.AddResponseCompression(options =>
{
    options.Providers.Add<GzipCompressionProvider>();
    options.MimeTypes = ResponseCompressionDefaults.MimeTypes.Concat(new[] {"image/svg+xml"});
});
services.Configure<GzipCompressionProviderOptions>(options =>
{
    options.Level = CompressionLevel.Optimal;
});

在“配置”中,我有

app.UseResponseCompression();
app.UseStaticFiles(new StaticFileOptions
{
    OnPrepareResponse = ctx =>
    {
        ctx.Context.Response.Headers[HeaderNames.CacheControl] = "public, max-age=31536000, immutable";
        ctx.Context.Response.Headers[HeaderNames.Vary] = new[] { "Accept-Encoding" };
        ctx.Context.Response.Headers["Keep-Alive"] = new[] { "timeout=5, max=100" };
    }
});

其他文件已压缩,但SVG未压缩。为什么会这样?

0 个答案:

没有答案