There's another option, as I showed in the session: IIS HTTP compression. IIS has the capability of compressing, on the fly, static (HTM, HTML, CSS) files as well as dynamic files (ASPX, AXD). By simply turning HTTP compression on, your payload will shrink a bit... in the case of the session demo, it shank by roughly 21%, with no changes to the site codebase or SharePoint itself! Check it out for yourself... below on the left is a screenshot of Fiddler at an OOTB Publishing Portal site and on the right you see the results of the changes I've made below (this was done on IIS v7):
|Publishing Portal OOTB configuration||Publishing Portal after bumping the compression level up to 9|
By default, HTTP compression is turned off but when SharePoint provisions a web application, it enables both static and dynamic compression. HTTP compression differs a bit from IIS v6 (Windows 2003) and IIS v7 (Windows 2008).
Know that HTTP compression is a CPU intensive process so the higher the level, the more your CPU is going to be stressed. Both IIS v6 and IIS v7 allow you to set the compression level, a scale of 0-10 with 10 being the highest compression level. I'd recommend you push it as high as you can without negatively affecting the performance of the overall web server.
HTTP Compression in IIS v6 (Windows 2003)
- First, you need to add a few static files to the list of static & dynamic file types by entering the following commands:
Add HTM, HTML, TXT, CSS and JS files to static compression.
CSCRIPT.EXE ADSUTIL.VBS SET W3Svc/Filters/Compression/DEFLATE/HcFileExtensions "htm" "html" "txt" "css" "js"
CSCRIPT.EXE ADSUTIL.VBS SET W3Svc/Filters/Compression/GZIP/HcFileExtensions "htm" "html" "txt" "css" "js"
Add ASP, EXE, ASPX and AXD files to dynamic compression.
CSCRIPT.EXE ADSUTIL.VBS SET W3Svc/Filters/Compression/DEFLATE/HcScriptFileExtensions "asp" "exe" "axd" "aspx"
CSCRIPT.EXE ADSUTIL.VBS SET W3Svc/Filters/Compression/GZIP/HcScriptFileExtensions "asp" "exe" "axd" "aspx"
- Next, you can configure the compression level. Static is already set to 10, but you can bump up the dynamic as high as your server can handle... the following bumps it up to 9:
CSCRIPT.EXE ADSUTIL.VBS SET W3Svc/Filters/Compression/DEFLATE/HcDynamicCompressionLevel "9"
CSCRIPT.EXE ADSUTIL.VBS SET W3Svc/Filters/Compression/GZIP/HcDynamicCompressionLevel "9"
HTTP Compression in IIS v7 (Windows 2008)
In IIS v6 HTTP compression is configured on a file type by file type using the file type extension whereas in IIS v7 it's configured using MIME types. IIS v7 also adds some additional capabilities such as allowing the generated HTML markup from ASP.NET to be compressed before being added to the page output cache & also to dynamically set when compression is switched on/off based on how stressed the CPU is.
Thankfully the MIME types we're interested in area already configured so there's nothing for us to add there like we had to in IIS v6.
- To set the compression level, open the C:\Windows\System32\inetsrv\config\applicationHost.config file and jump to the <httpCompression> section (around line 574). Add the dynamicCompressionLevel attribute to the <schema> node like this:
<scheme [..] dynamicCompressionLevel="9" />
- Next, tell IIS v7 to add compressed pages to the ASP.NET page output cache instead of deferring the caching until the request pulls it from cache:
APPCMD.EXE set config -section:httpCompression /dynamicCompressionDisableCpuUsage:75
APPCMD.EXE set config -section:httpCompression /dynamicCompressionEnableCpuUsage:20
- Finally, configure IIS v7 to dynamically turn caching on/off based on the utilization of the server... below I'm telling it to only compress when the CPU utilization is between 20-75%:
APPCMD.EXE set config -section:urlCompression /dynamicCompressionBeforeCache:true
Take one last thing into consideration: your mileage may vary. What I mean by this is that every environment, site and usage is different. The settings I list here may or may not work for you. Like any performance optimization process, you need to adjust the tuning knobs, test and analyze the results to find what works best for your environment. I'm using a compression level of 9 simply to show how much it can help you. I've heard some say don't go above 4... personally I don't see why you shouldn't go as high as you can as long as the CPU can handle it. So again... your mileage may vary.