I am adding in gzipping to all my static content, and html outputs from my .net 4 site.
I also have compression enabled in IIS 7.5 (both static and dynamic), and what I am finding is that enabling compression in IIS, overwrites my Vary: Accept-Encoding header for these resources.
So, what I am wondering is, is there really a need to enable compression in IIS, since I already am gzipping things?
So, I've done a some testing, and what I found follows:
Utilizing IIS Static and Dynamic Compression, with code compression:
CPU Load: 35%
Memory Load: 28M
Utilizing IIS Static and Dynamic Compression, without code compression:
CPU Load: 34%
Memory Load: 28M
Non-Utilizing Static and Dynamic Compression In IIS, with code compression:
CPU Load: 14%
Memory Load: 32M
So, based on my findings, I agree, there is no need to utilize IIS compression, when doing this in code. Even though memory consumption is a bit higher, CPU Load is significantly enough lower to make the in-code compression much more efficient for serving the files.
Now, really my whole point of this was to find out and get rid of the IIS overwriting of the Vary: Accept-Encoding header. Which, it seems to have no effect when IIS compression is enabled or not. The header still does not get added... so, can you help with that?
Here is the code for the caching that I am implementing, please note that prior to firing the method containing this code, I am clearing the headers via, context.Response.ClearHeaders():
With context.Response
.AddHeader("Cache-Control", "store, cache")
.AddHeader("Pragma", "cache")
.AddHeader("Cache-Control", "max-age=21600")
.AddHeader("ETag", Date.Now.Ticks)
.AddHeader("Expires", DateTime.Now.AddYears(1).ToString("ddd, dd MMM yyyy hh:mm:ss") + " GMT")
.AddHeader("Vary", "Accept-Encoding")
.AppendHeader("Vary", "Accept-Encoding")
.Cache.SetVaryByCustom("Accept-Encoding")
.Cache.SetOmitVaryStar(True)
.Cache.VaryByParams.IgnoreParams = True
.Cache.SetAllowResponseInBrowserHistory(True)
.Cache.SetCacheability(Web.HttpCacheability.Public)
.Cache.SetValidUntilExpires(True)
.Cache.SetLastModified(DateTime.Now.AddYears(-1).ToString("ddd, dd MMM yyyy hh:mm:ss") + " GMT")
.CacheControl = "public" '
.Expires = 24 * 60 * 366
.ExpiresAbsolute = DateTime.Now.AddYears(1).ToString("ddd, dd MMM yyyy hh:mm:ss") + " GMT"
End With