开发者

how can compress data

1. My host uses IIS 7 and IIS is not my right to access settings. Now how do the web.config or the other I sent a js/css/aspx to apply the Gzip.

2.how can enable etags for iis6

how can enable this for my web site this not work(Yslow)

<httpCompression directory="%SystemDrive%\inetpub\temp\IIS Temporary Compressed Files">
            <scheme name="gzip" dll="%Win开发者_JAVA百科dir%\system32\inetsrv\gzip.dll"/>
            <dynamicTypes>
                <add mimeType="text/*" enabled="true"/>
                <add mimeType="message/*" enabled="true"/>
                <add mimeType="application/javascript" enabled="true"/>
                <add mimeType="*/*" enabled="false"/>
            </dynamicTypes>
            <staticTypes>
                <add mimeType="text/*" enabled="true"/>
                <add mimeType="message/*" enabled="true"/>
                <add mimeType="application/javascript" enabled="true"/>
                <add mimeType="*/*" enabled="false"/>
            </staticTypes>
        </httpCompression>
        <urlCompression doStaticCompression="true" doDynamicCompression="true"/>

Edit

this code in gloabal.asax good work but still Yslow show does not use Gzip??

void Application_PreRequestHandlerExecute(object sender, EventArgs e) { HttpApplication app = sender as HttpApplication; string acceptEncoding = app.Request.Headers["Accept-Encoding"]; Stream prevUncompressedStream = app.Response.Filter;

    if (!(app.Context.CurrentHandler is Page ||
        app.Context.CurrentHandler.GetType().Name == "SyncSessionlessHandler") ||
        app.Request["HTTP_X_MICROSOFTAJAX"] != null)
        return;

    if (acceptEncoding.Contains("gzip") )
        return;

    acceptEncoding = acceptEncoding.ToLower();

    if (acceptEncoding.Contains("deflate") || acceptEncoding == "*")
    {
        // gzip
        app.Response.Filter = new GZipStream(prevUncompressedStream,
            CompressionMode.Compress);
        app.Response.AppendHeader("Content-Encoding", "gzip");


    }
    else if (acceptEncoding == null || acceptEncoding.Length == 0)
    {
        // defalte
        app.Response.Filter = new DeflateStream(prevUncompressedStream,
            CompressionMode.Compress);
        app.Response.AppendHeader("Content-Encoding", "deflate");

    }
}

Article Link


I believe that implementing compression in code is the wrong approach; I understand your situation and I am sure it's difficult, but I would consider moving to another host.

this code in gloabal.asax good work but still Yslow show does not use Gzip??

Do you mean that it works when you test locally, but not when it's deployed to the host? I've definitely seen some proxies (e.g. corporate gateways) remove the "accept-encoding gzip" from the wire, so that might be something to consider.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜