<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.dirteam.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>The way I did it : chache, Forefront, Windows</title><link>http://blogs.dirteam.com/blogs/chrispetit/archive/tags/chache/Forefront/Windows/default.aspx</link><description>Tags: chache, Forefront, Windows</description><dc:language>en</dc:language><generator>CommunityServer 2.1 SP3 (Build: 20423.1)</generator><item><title>TMG Compression broke my site</title><link>http://blogs.dirteam.com/blogs/chrispetit/archive/2012/02/08/tmg-chaching-and-compression.aspx</link><pubDate>Wed, 08 Feb 2012 14:04:36 GMT</pubDate><guid isPermaLink="false">4afa41f1-c118-406e-beda-ba054a9f6c33:6022</guid><dc:creator>ChrisPetit</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.dirteam.com/blogs/chrispetit/comments/6022.aspx</comments><wfw:commentRss>http://blogs.dirteam.com/blogs/chrispetit/commentrss.aspx?PostID=6022</wfw:commentRss><description>&lt;p&gt;Microsoft Threat Management Gateway (&lt;a href="http://www.microsoft.com/tmg" target="_blank"&gt;TMG&lt;/a&gt;) should make publishing websites easy. Generally it is. We had a configuration as shown below:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.dirteam.com/blogs/chrispetit/Drawing2_085313C9.png"&gt;&lt;img style="background-image:none;border-right-width:0px;padding-left:0px;padding-right:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;" title="Drawing2" border="0" alt="Drawing2" src="http://blogs.dirteam.com/blogs/chrispetit/Drawing2_thumb_35D4338C.png" width="518" height="114" /&gt;&lt;/a&gt;     &lt;br /&gt;&lt;/p&gt;  &lt;p&gt;This should work like a charm. Unfortunately it did not in Internet Explorer 9. Upon testing the published site we noticed that some of the SharePoint functionality was not working as intended; Menu functions were not correctly created in the published page. If you visited through an InPrivate session the problem disappeared. Other browsers, such as Chrome and Firefox did not seem to suffer. Also the situation was a little more complicated:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.dirteam.com/blogs/chrispetit/Drawing3_00C7A45C.png"&gt;&lt;img style="background-image:none;border-right-width:0px;padding-left:0px;padding-right:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;" title="Drawing3" border="0" alt="Drawing3" src="http://blogs.dirteam.com/blogs/chrispetit/Drawing3_thumb_070E7AEA.png" width="520" height="236" /&gt;&lt;/a&gt;     &lt;br /&gt;&lt;/p&gt;  &lt;p&gt;When we connected from to the published site from the webserver, there was no problem. When we modified the hosts file to bypass the TMG there was no problem. So it seems that the TMG was altering something. And it did. &lt;/p&gt;  &lt;p&gt;Since the bulk of the users was connected through a satellite connection which had narrow bandwidth we used some compression methods on the webserver. &lt;/p&gt;  &lt;p&gt;Upon testing extensively we determined that the default.css remained empty. This clearly was a caching problem resulting from the TMG configuration. &lt;/p&gt;  &lt;p&gt;Eventually we narrowed it down to the Web access policy and the Web Compression Filter on the TMG. turning those off made the problem disappear on the clients.&lt;/p&gt;  &lt;p&gt;Since we wanted the Compression Filter to work for some of the websites we had to come up with another solution than simply disabling the filter. After some searching we came across a MSDN article describing the &lt;a href="http://msdn.microsoft.com/en-us/library/ff827091%28v=vs.85%29.aspx" target="_blank"&gt;&lt;strong&gt;SendAcceptEncodingHeader&lt;/strong&gt;&lt;/a&gt;&lt;strong&gt;. &lt;/strong&gt;The VBscript below can be run on the TMG. It sets the &lt;strong&gt;SendAcceptEncodingHeader &lt;/strong&gt;property&lt;strong&gt; &lt;/strong&gt;to &lt;strong&gt;true&lt;/strong&gt; for a specific publishing rule on the TMG. This will allow compressed content from the webserver to reach the clients correctly.     &lt;br /&gt;    &lt;br /&gt;&lt;/p&gt;  &lt;pre&gt;&lt;strong&gt;&lt;hr /&gt;&lt;/strong&gt;' Define the constants needed
const Error_FileNotFound = &amp;amp;H80070002
Const fpcPolicyWebPublishing = 2
Main(WScript.Arguments)
Sub Main(args)
    If(args.Count = 1) Then
        AllowCompressedContent args(0)
    Else
        Usage()
    End If
End Sub
Sub AllowCompressedContent(ruleName)
    ' Create the root object.
    Dim root  ' The FPCLib.FPC root object
    Set root = CreateObject(&amp;quot;FPC.Root&amp;quot;)
    ' Declare the other objects needed.
    Dim isaArray        ' An FPCArray object
    Dim rule            ' An FPCPolicyRule object
    ' Get a reference to the array object.
    Set isaArray = root.GetContainingArray()
    ' Get a reference to the policy rule specified.
    On Error Resume Next
    Set rule = isaArray.ArrayPolicy.PolicyRules.Item(ruleName)
    If Err.Number = Error_FileNotFound Then
        WScript.Echo &amp;quot;The policy rule specified could not be found.&amp;quot;
    Else
        Err.Clear
        On Error GoTo 0
        If rule.Type = fpcPolicyWebPublishing Then
            If rule.WebPublishingProperties.SendAcceptEncodingHeader = False _
                    Then
                rule.WebPublishingProperties.SendAcceptEncodingHeader = True
                rule.Save
                WScript.Echo &amp;quot;Done!&amp;quot;
            Else
                WScript.Echo &amp;quot;The policy rule specified already &amp;quot; &amp;amp; _ 
                    &amp;quot;allows forwarding of compressed content.&amp;quot;
            End If
        Else
            WScript.Echo &amp;quot;The policy rule specified is not a Web publishing rule.&amp;quot;
        End If
    End If
End Sub
Sub Usage()
    WScript.Echo &amp;quot;Usage:&amp;quot; &amp;amp; VbCrLf _
        &amp;amp; &amp;quot;  &amp;quot; &amp;amp; WScript.ScriptName &amp;amp; &amp;quot; RuleName&amp;quot; &amp;amp; VbCrLf _
        &amp;amp; &amp;quot;&amp;quot; &amp;amp; VbCrLf _
        &amp;amp; &amp;quot;    RuleName - Name of the Web publishing rule&amp;quot; 
    WScript.Quit
End Sub&lt;strong&gt;&lt;hr /&gt;&lt;/strong&gt;&lt;/pre&gt;

&lt;p&gt;By default a web publishing rule instructs the TMG to delete all Accept-Encoding headers sent to the webserver. However the webserver answers with compressed responses. The TMG in turn will not forward the compressed responses. That’s when, for instance, the piece of java that makes up your SharePoint menu items brakes. &lt;/p&gt;

&lt;h3&gt;Conclusion&lt;/h3&gt;

&lt;p&gt;Let me point out that this will not be an issue when you are not using compression on the webserver. If you do however, and do not want to turn off all of the compression on TMG then you might find the script helpful. &lt;/p&gt;

&lt;p&gt;I’d like to see this property of a web publishing rule to be an option in the GUI. In my opinion, especially considering the fact that a lot of clients, including mobile devices, benefit from compression, this would be a nice option which should be more accessible. Maybe a checkbox in the publishing rule wizard or properties. 
  &lt;br /&gt;&lt;/p&gt;&lt;img src="http://blogs.dirteam.com/aggbug.aspx?PostID=6022" width="1" height="1"&gt;</description><category domain="http://blogs.dirteam.com/blogs/chrispetit/archive/tags/R2/default.aspx">R2</category><category domain="http://blogs.dirteam.com/blogs/chrispetit/archive/tags/Server/default.aspx">Server</category><category domain="http://blogs.dirteam.com/blogs/chrispetit/archive/tags/2008/default.aspx">2008</category><category domain="http://blogs.dirteam.com/blogs/chrispetit/archive/tags/Windows/default.aspx">Windows</category><category domain="http://blogs.dirteam.com/blogs/chrispetit/archive/tags/SendAcceptEncodingHeader/default.aspx">SendAcceptEncodingHeader</category><category domain="http://blogs.dirteam.com/blogs/chrispetit/archive/tags/Forefront/default.aspx">Forefront</category><category domain="http://blogs.dirteam.com/blogs/chrispetit/archive/tags/chaching/default.aspx">chaching</category><category domain="http://blogs.dirteam.com/blogs/chrispetit/archive/tags/TMG/default.aspx">TMG</category><category domain="http://blogs.dirteam.com/blogs/chrispetit/archive/tags/Sharepoint/default.aspx">Sharepoint</category><category domain="http://blogs.dirteam.com/blogs/chrispetit/archive/tags/chache/default.aspx">chache</category><category domain="http://blogs.dirteam.com/blogs/chrispetit/archive/tags/compression/default.aspx">compression</category></item></channel></rss>