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%inetpubtempIIS Temporary Compressed Files">
            <scheme name="gzip" dll="%Windir%system32inetsrvgzip.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 (eg corporate gateways) remove the "accept-encoding gzip" from the wire, so that might be something to consider.

链接地址: http://www.djcxy.com/p/7610.html

上一篇: 文本框和标签数组如何在c#中提交方法中获取值

下一篇: 如何压缩数据