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

Application_PreRequestHandlerExecute (ByVal As the object, ByVal e EventArgs as) or if not in as dim response HttpResponse = HttpContext.Current.Response dim AcceptEncoding string = HttpContext.Current.Request.Headers ( "accept -anankoding"), accept Stringkaisaielolakti (encoding) Awrael Therefore AcceptEncoding.Contains ("gzip") OrElse Ac ceptEncoding.Contains ( "deflation") above the AcceptEncoding.Contains (remove the "air") then Response.Filter = new System.IO.Compression.DeflateStream (Response.Filter, System.IO. Compression.CompressionMode.Compress) Response .AppendHeader ( "content-encoding", "remove air") or Response.Filter = new System.IO.Compression.GZipStream (Response.Filter, System.IO.Compression.CompressionMode.Compress) response. Ended Android ("content-encoding", "jizip") and end if response. Appenders ("Miscellaneous", "Content-Encoding") and all

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

Popular posts from this blog

oracle - The fastest way to check if some records in a database table? -

php - multilevel menu with multilevel array -

jQuery UI: Datepicker month format -