asp.net - Grade D on Compress components with gzip -
I have used the YSlow Firefox add-on and the result comes back:
- --- ----------------------------------------------- --- -----------------------------------
Compress components with gzip on Grade D <3 p>
Website / CSS / Global CSS? ... * http: // localhost: 63808 / website / js / global.js? ...
------------- ----------------------- --------------------------------------------------- --- - Then I started searching and found this piece of code:
global asax
And now I have:
Compress components with gzip on grade A
Okay, we? The question is: Is the application_prerequestHandlerExecute event the best place to gzip / deflate events?
Not sure but your code may cause problems in pages using Ajax Shows similar code but if Ajax is detected then cancel compression. I translated the code into VB, but he did not try.
Eric
private sub Application_PreRequestHandlerExecute (object as ByVal sender, EventArgs as ByVal) Dim in HttpApplication = TryCast (from the app, HttpApplication) dim acceptEncoding as string = app.Request.Headers ( "Accept-Encoding") dim prevUncompressedStream stream = app.Response.Filter do not (typeof app.Context.CurrentHandler page OrElse as app.Context.CurrentHandler. [GetType] () .name = "SyncSessionlessHandler") OrElse app.Request ("HTTP_X_MICROSOFTAJAX") if nothing isnot then return notnot then acceptEncoding nothing OrElse acceptEncoding.Length = 0 then return end, then if acc eptEncoding = acceptEncoding.ToLower () if acceptEncoding.Contains ( "deflation") OrElse acceptEncoding = "*" then 'defalte app.Response.Filter = new DeflateStream (prevUncompressedStream, CompressionMode.Compress) app.Response.AppendHeader ( "Content Encoding "," air extract ") elseif acceptEncoding. ("Gzip") occurs when the 'gzip app.Respo Nse.filter = new gzipstream (Proc Compressed Stream, Compression Mode.Compress) app. response. The append header ("content-encoding", "jizip") and end
and all
Comments
Post a Comment