HTTP / 2图像加载时间-等待最后一个完成

这让我感到困惑。在新服务器(Windows Server 2016)上,我的图像似乎正在同步加载。浏览器正在尝试同时下载所有图像,但是某些操作阻止了图像的加载,直到上一个图像完成为止。尝试加载每个图像时,到第一个字节的时间增加。

编辑:我已经在下面发布了我的图像处理程序代码,但是您可以看到以原始格式加载.jpg时存在问题(请参见屏幕快照约一半)。

编辑2:我已禁用http / 2并添加了屏幕截图。

HTTP / 2图像加载时间-等待最后一个完成

我的SVG图像处理程序代码(image.ashx也存在问题):

    Dim freshness As TimeSpan = New TimeSpan(1,0)
    Dim now As DateTime = DateTime.Now
    Response.Cache.SetExpires(now.Add(freshness))
    Response.Cache.SetMaxAge(freshness)
    Response.Cache.SetCacheability(HttpCacheability.Public)
    Response.Cache.SetValidUntilExpires(True)

    Response.Cache.VaryByParams("colour") = True
    Response.Cache.VaryByParams("colour2") = True
    Response.Cache.VaryByParams("svg") = True
    Response.Cache.VaryByParams("rnd") = True
    Response.Cache.VaryByHeaders("rnd") = True
    Response.Cache.VaryByHeaders("Type") = True


    Dim sSVG As String = Request.QueryString("svg").Split("-")(0)
    If sSVG = String.Empty Then
        Try
            sSVG = Request.ServerVariables("SCRIPT_NAME").Split("-")(0)
        Catch ex As Exception
            sSVG = "svg"
        End Try
    End If


    Dim xDoc As XDocument = XDocument.Load(Server.MapPath("\images\icons\svg\" & sSVG & ".svg"))

    Dim sColour As String = "FFFFFF"
    Dim sColour2 As String = "FFFFFF"
    Dim sXML As String = xDoc.Document.ToString
    If Request.QueryString("Colour") <> String.Empty Then
        sColour = Request.QueryString("Colour")
    Else
        Try
            sColour = sSVG.Split("-")(1)
        Catch ex As Exception
        End Try
    End If
    If Request.QueryString("Colour2") <> String.Empty Then
        sColour2 = Request.QueryString("Colour2")
    Else
        Try
            sColour = sSVG.Split("-")(2)
        Catch ex As Exception
        End Try
    End If

    sXML = sXML.Replace("COLOUR2",sColour2)
    sXML = sXML.Replace("COLOUR",sColour)

    Response.Headers.Add("Vary","accept-Encoding")
    response.contenttype = "image/svg+xml"
    Response.Write(sXML)

禁用HTTP / 2:

HTTP / 2图像加载时间-等待最后一个完成

myyxd318 回答:HTTP / 2图像加载时间-等待最后一个完成

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/3169831.html

大家都在问