Hi, I used the YSlow Firefox add-on and it return the follow result:
-----------------------------------------------------------------------------------------
Grade D on Compress components with gzip
There are 3 plain text components that should be sent compressed
* http://localhost:63808/WebSite/BemVindo/
* http://localhost:63808/WebSite/css/Global.css?...
* http://localhost:63808/WebSite/js/Global.js?...
-----------------------------------------------------------------------------------------
So I started to search and got this piece of code:
Global.asax
Private Sub Application_PreRequestHandlerExecute(ByVal sender As Object, ByVal e As EventArgs)
Dim Response As HttpResponse = HttpContext.Current.Response
Dim AcceptEncoding As String = HttpContext.Current.Request.Headers("Accept-Encoding")
If Not String.IsNullOrEmpty(AcceptEncoding) AndAlso AcceptEncoding.Contains("gzip") OrElse AcceptEncoding.Contains("deflate") Then
If AcceptEncoding.Contains("deflate") Then
Response.Filter = New System.IO.Compression.DeflateStream(Response.Filter, System.IO.Compression.CompressionMode.Compress)
Response.AppendHeader("Content-Encoding", "deflate")
Else
Response.Filter = New System.IO.Compression.GZipStream(Response.Filter, System.IO.Compression.CompressionMode.Compress)
Response.AppendHeader("Content-Encoding", "gzip")
End If
End If
Response.AppendHeader("Vary", "Content-Encoding")
End Sub
And now I have:
Grade A on Compress components with gzip
Fine, hum? The question is: Is the Application_PreRequestHandlerExecute event the best place to gzip/deflate the requests?