Forum Discussion

Ian_Stewart_390's avatar
Ian_Stewart_390
Icon for Nimbostratus rankNimbostratus
Jan 05, 2005

Compress::Enable

Hi Everyone,

 

 

I would like to selectively compress HTTP responses from our server to the client browser. Because of the following IE bugs:

 

 

For IE 5.5 : http://support.microsoft.com/default.aspx?scid=kb;en-us;Q313712

 

 

For IE 6.0 : http://support.microsoft.com/default.aspx?scid=kb;en-us;Q312496

 

 

I want to make the decision based on two factors: the User-Agent header of the request, and the Content-Type of the response. Is that possible to do? How would I write an iRule that connects a HTTP response content type with the HTTP request user-agent that asked for it?

 

 

Thanks!

 

 

-Ian
  • Here's what I've tried:

     

     

    A single rule:

     

     

    when HTTP_REQUEST {

     

    set hdr_user_agent [string tolower [HTTP::header User-Agent]]

     

    if { $hdr_user_agent contains "firefox" or $hdr_user_agent contains "msie 6.0" } {

     

    set client_ok 1

     

    log local0. "Header agent $hdr_user_agent compressed"

     

    }

     

    else {

     

    set client_ok 0

     

    }

     

    }

     

     

    when HTTP_RESPONSE {

     

    set hdr_content_type [string tolower [HTTP::header Content-Type]]

     

    if { $hdr_content_type contains "text" or $hdr_content_type contains "message" } {

     

    if { $client_ok == 1} {

     

    COMPRESS::enable

     

    }

     

    }

     

    }

     

    And other than enabling compression in the HTTP profile as selective, no other settings.

     

     

    But that fails with "TCL error: Rule Selective_Compression - Error: Unknown error (line 1) invoked from within "COMPRESS::enable" "

     

    ----------------------------------------------------

     

    I've also tried this:

     

     

    when HTTP_REQUEST {

     

    set hdr_user_agent [string tolower [HTTP::header User-Agent]]

     

    if { $hdr_user_agent contains "firefox" or $hdr_user_agent contains "msie 6.0" } {

     

    COMPRESS::enable

     

    }

     

    }

     

     

    And then configuring in the HTTP profile to only compress certain content (again, selectively), but I get the same error message.

     

     

    What am I doing wrong?

     

     

    -Ian
  • John_Pruitt_33's avatar
    John_Pruitt_33
    Historic F5 Account
    All COMPRESS:: commands are currently broken in 9.0.3 and will exhibit this behavior. We will create a hotfix for this.
  • If I am using 9.1 and enable compression, do I have to worry about these

     

     

    For IE 5.5 : http://support.microsoft.com/default.aspx?scid=kb;en-us;Q313712

     

     

    For IE 6.0 : http://support.microsoft.com/default.aspx?scid=kb;en-us;Q312496

     

     

    that are mentioned in the top of this post?

     

     

    Do I use the "browser workaround" functions to get past these problems?

     

     

    Thanks,

     

     

    Drew
  • Colin_Walker_12's avatar
    Colin_Walker_12
    Historic F5 Account
    The two issues that were linked to at the top of this post have to do with browser issues with compression, not the BIG-IP itself.

     

     

    So yes, you'll likely still want to take those into consideration when building your compression code.

     

     

    -Colin
  • unRuleY_95363's avatar
    unRuleY_95363
    Historic F5 Account
    We are looking at the best way to work around these potential issues and will post a follow-up.
  • I am enabling compression and the problem described here seems to rule out compression of javascript and css for IE 6.0.

     

     

    http://support.microsoft.com/kb/312496

     

     

    The first 2048 bytes of CSS and Javascript files get lost and pages end up looking funny or scripts don't work.

     

     

    The user-agent for IE6.0 and IE6.0SP1 is the same so I can't selectively compress based on browser unless there is another way to detect that.

     

     

    Would it be too much of a hack to pad large javascript files with comments at the beginning so they could be compressed without IE losing anything important? We have some really large javascript files so it would be nice to compress them.

     

     

    If I turn on browser workarounds in the profile it seems to fix the problem by turning off caching for IE. Are those browser work around rules defined anywhere? I am wondering if 9.2.2 knows about IE 7.0.
  • Set your http profile compress setting to selective and use the following gzip rule. This has addressed our problem by selectively compressing known big files that we serve.

     

     

    when HTTP_REQUEST {

     

    set hdr_user_agent [string tolower [HTTP::header User-Agent]]

     

    if { $hdr_user_agent contains "windows 98" }

     

    { COMPRESS::disable }

     

    else

     

    { if { $hdr_user_agent contains "msie 5." or

     

    $hdr_user_agent contains "msie 6.0"}

     

    { if { [matchclass [HTTP::uri] contains $::compressed_files]}

     

    { COMPRESS::enable }

     

    else

     

    { COMPRESS::disable }

     

    }

     

    else

     

    { COMPRESS::enable }

     

    }

     

    }
  • We don't do a whole lot of compression tweaking, but do use a ton of caching which should translate nearly one2one. I've found that with caching that using CACHE::enable in my irule causes some problems by overriding the caching parms in the profile. You might see more consistent behavior in the long run if you use the profile to compress by default, and write your irules to NOT compress selectively.

     

     

    Just my 2 cents