English 中文(简体)
GZIP 造成网页过期的压缩
原标题:GZIP Compression causing web page expiration
  • 时间:2009-11-19 08:41:06
  •  标签:
  • asp.net
  • gzip

我已经在我的几家协会上调了GZIP压缩机。 NET页面,使用从系统继承的类别。 Web.UI.Page, and implementing the OnLoad methods to do the compression, as so:

    protected override void OnLoad(EventArgs e)
    {
        base.OnLoad(e);

        if (Internet.Browser.IsGZIPSupported())
        {
            base.Response.Filter = new GZipStream(base.Response.Filter, CompressionMode.Compress, true);
            base.Response.AppendHeader("Content-encoding", "gzip");
            base.Response.AppendHeader("Vary", "Content-encoding");
        }
        else if (Internet.Browser.IsDeflateSupported())
        {
            base.Response.Filter = new DeflateStream(base.Response.Filter, CompressionMode.Compress, true);
            base.Response.AppendHeader("Content-encoding", "deflate");
            base.Response.AppendHeader("Vary", "Content-encoding");
        }
    }

IsGZIP的辅助方法只是确定浏览器是否支持GZIP,看看接收编码要求负责人和浏览器用户(IE5-6)是否被排除在GZIP压缩机之外。 然而,根据这一守则,我正在看到该网页已经过期,当时我从网页上接过来,试图使用背顿语。 确立对私人的切身控制似乎在解决这个问题:

base.Response.Cache.SetCacheability(HttpCacheability.Private);

但我不清楚为什么,或者这是否会造成其他问题。 我的斜线为网站的任何其他页面打上任何剪辑,而该网站的内联网只有十几个同时用户,因此,目前业绩是一个大问题。

最佳回答
问题回答

暂无回答




相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Transaction handling with TransactionScope

I am implementing Transaction using TransactionScope with the help this MSDN article http://msdn.microsoft.com/en-us/library/system.transactions.transactionscope.aspx I just want to confirm that is ...

System.Web.Mvc.Controller Initialize

i have the following base controller... public class BaseController : Controller { protected override void Initialize(System.Web.Routing.RequestContext requestContext) { if (...

Microsoft.Contracts namespace

For what it is necessary Microsoft.Contracts namespace in asp.net? I mean, in what cases I could write using Microsoft.Contracts;?

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签