X-flash-version header can prevent ISA/TMG from compressing contents
In this blog post I want to discuss a solution, which we provided to one of our customers.
The problem was linked to a published web site where specific flash content had not been compressed as expected by TMG/ISA.
The first thing which is important to mention is, that it usually it not necessary to compress flash content. My customer had the need to compress the content because of the client which was accessing the data was connected via a slow satellite link. When analyzing the ISAInfo (http://www.isatools.org/tools/isainfo.zip) output generated by the TMG BPA (http://www.microsoft.com/download/en/details.aspx?id=17730), we could see that ISA-TMG skips the compression for the following contents:
Compression Settings ... |
HTTP headers exempt from compression |
x-flash-version: |
User-Agents exempt from compression |
*BITS* |
Hence if we want to compress this kind of content we need to “force” ISA/TMG to do it.
Please be aware that with the following changes I want to demonstrate the things you can do by modifying COM properties through scripting in ISA/TMG. Please be aware that all changes you perform through scripts, bypass all the logic verifiers, which are implemented in the UI. Always make a backup of your configuration before performing any changes with a script. Microsoft cannot guarantee that problems resulting from incorrect use of these scripts can be solved! Even if this solution was applied successfully by my customer and tested for a while in his specific environment, this is something Microsoft didn’t test extensively and hence the implementation of the solution itself is at its own risk!
Let’s have a look at the traces to better understand what we are talking about:
The following is a network trace taken before applying our script to modify the compression settings of our ISA-TMG machine:
Allowed www.contoso.com access (test) x.x.x.x Remote Client x.x.x.x 3000 www.contoso.com POST 200
…
POST /xmlservice/RemoteFramework/http/update HTTP/1.1
Referer: app:/core.html
Accept: text/xml, application/xml, application/xhtml+xml, text/html;q=0.9, text/plain;q=0.8, text/css, image/png, image/jpeg, image/gif;q=0.8, application/x-shockwave-flash, video/mp4;q=0.9, flv-application/octet-stream;q=0.8, video/x-flv;q=0.7, audio/mp4, application/futuresplash, */*;q=0.5
x-flash-version: 10,3,181,34
Content-Type: text/xml
…
Content-Length: 110
Accept-Encoding: gzip,deflate
User-Agent: Test Remote Client
Host: www.contoso.com
Connection: Keep-Alive
Cache-Control: no-cache
<update xmlns="test:remoteframework" id="{c095c364-ec83-4cf8-b79b-83601bd1e78e}" version="2011.1.0.22" />
As we can see the response is NOT compressed:
HTTP/1.1 200 OK
Connection: Keep-Alive
Transfer-Encoding: chunked
Content-type:text/xml;charset=UTF-8
<?xml version="1.0" encoding="UTF-8"?>
<model xmlns="test:remoteframework"><meta><class up="6EDB::2"><attribute up="6EDB::6" type="text" /><attribute up="6EDB::7" type="pointer" /><attribute up="6EDB::75" type="pointer" /><attribute up="6EDB::65" type="pointer" /><attribute up="6EDB::76" type="boolean" /></class><class up="6EDB::1"><attribute up="6EDB::3
....
<object up="91E4C2::6"><value attribute="46A5D6::262">(PAS) rapport</value></object><object up="91E4C2::8"><value attribute="46A5D6::262">(PAS) # en €</value></object></class><class up="46A5D6::117" /><class up="46A5D6::116" /><class up="46A5D6::118" /><class up="46A5D6::121" /><class up="46A5D6::122" /></data></model>
0
…
To change the compression behavior, we had to remove the x-flash-version entry from the list of incompressible content in the configuration. As there’s no UI option for this we had to perform these steps by directly modifying the COM properties. Afterwards TMG/ISA did compress the content as requested by the customer.
In the following I want to describe in detail how we can interact with the COM properties.
We can start from the following URL: http://msdn.microsoft.com/en-us/library/ff824938(v=VS.85).aspx
With the following VBScript we can verify which headers are included in the TMG list of non-compressible content:
' Create the root object.
Dim root ' The FPCLib.FPC root object
Set root = CreateObject("FPC.Root")
' Declare the other objects needed.
Dim isaArray ' An FPCArray object
Dim httpHeaders ' An FPCHTTPHeaders collection
Dim httpHeader ' A String
' Get references to the array object
' and the HTTP headers collection.
Set isaArray = root.GetContainingArray()
With isaArray.ArrayPolicy.WebProxy.HTTPCompressionConfiguration
Set httpHeaders = .UnsupportedHeaders
End With
' Display the unsupported HTTP headers.
For Each httpHeader In httpHeaders
WScript.Echo httpHeader
Next
WScript.Echo "done!"
For more information the following link describes the TMG Administration object model:
http://msdn.microsoft.com/en-us/library/ff824018(v=VS.85).aspx
This article gives us an idea which methods and proprieties are supported by the FPCHTTPHeaders collection object:
http://msdn.microsoft.com/en-us/library/ff824942(v=VS.85).aspx
At this point we can start writing the following scripts to remove the x-flash-version entry:
' Create the root object.
Dim root ' The FPCLib.FPC root object
Set root = CreateObject("FPC.Root")
' Declare the other objects needed.
Dim isaArray ' An FPCArray object
Dim httpHeaders ' An FPCHTTPHeaders collection
' Get references to the array object
' and the HTTP headers collection.
Set isaArray = root.GetContainingArray()
With isaArray.ArrayPolicy.WebProxy.HTTPCompressionConfiguration
Set httpHeaders = .UnsupportedHeaders
End With
httpHeaders.Remove(1)
httpHeaders.Save()
WScript.Echo "done!"
And just in case you want to re-add the header type, you can use this script_:
' Create the root object.
Dim root ' The FPCLib.FPC root object
Set root = CreateObject("FPC.Root")
' Declare the other objects needed.
Dim isaArray ' An FPCArray object
Dim httpHeaders ' An FPCHTTPHeaders collection
' Get references to the array object
' and the HTTP headers collection.
Set isaArray = root.GetContainingArray()
With isaArray.ArrayPolicy.WebProxy.HTTPCompressionConfiguration
Set httpHeaders = .UnsupportedHeaders
End With
httpHeaders.Add("x-flash-version:")
httpHeaders.Save()
WScript.Echo "done!"
At this point as we can see from the below test we have that the content is correctly compressed by ISA/TMG even if in the header of the packets the client application is still inserting the x-flash-version entry:
Host: www.contoso.com \r\n
POST /xmlservice/RemoteFramework/http/update HTTP/1.1
Referer: app:/core.html
Accept: text/xml, application/xml, application/xhtml+xml, text/html;q=0.9, text/plain;q=0.8, text/css, image/png, image/jpeg, image/gif;q=0.8, application/x-shockwave-flash, video/mp4;q=0.9, flv-application/octet-stream;q=0.8, video/x-flv;q=0.7, audio/mp4, application/futuresplash, */*;q=0.5
x-flash-version: 10,3,181,34
Content-Type: text/xml
…
Content-Length: 110
Accept-Encoding: gzip,deflate
User-Agent: Remote Client
Host: www.contoso.com
Connection: Keep-Alive
Cache-Control: no-cache
…
As we can see the response this time is compressed:
HTTP/1.1 200 OK
Connection: Keep-Alive
Content-length:56138
Content-type:text/xml;charset=UTF-8
Content-Encoding:gzip
Vary: Accept-Encoding
.....g.N...}k..D....+.>q.@,`.......X..M`..q.iz..pO..Zc0..H=O{.U........=ju.*_../....e..j7u....."..U.Es\.N.z......?........q...gW.....gm..iO..V.MW.l.....}.../O........l...W..w....?d.........n|n.d..u......{.=.?...Z7................i.U..>.p..mD..D..Q.....R@.......9[.~.Ldi.P*....I}[dv.......^*...C.....k...f..P2..Lf...R._.vqJ.....J...........=-.O..
Author
Andrea Vescovo
Support Engineer
Microsoft CSS Forefront Edge Team
**Technical Reviewer**Philipp Sand
Support Escalation Engineer
Microsoft CSS Forefront Edge Team
Comments
- Anonymous
January 03, 2012
Does TMG accept wildcard content types? text/* application/* etc?