Forum Discussion

TalNe's avatar
TalNe
Icon for Nimbostratus rankNimbostratus
Sep 20, 2016

How to get the response size after gzip compression

Hi, i have virtual server that run HTTP Compression Profile i need to get the size of the response packet after the gzip compression before it leave the f5 machine

 

i try the fallow irule

 

when HTTP_RESPONSE { log local0. "HTTP_RESPONSE triggered" HTTP::collect 32000000 set length [HTTP::payload length] HTTP::header insert "Content-Length" $length log local0. "the content length of the response from OWS is $length" } but i get the size before compression

 

i check the size its need to be with the fallow command from tmsh

 

tmsh show ltm profile http-compression profile_name

 

i will appreciate your help thanks

 

3 Replies

  • What version of BIG-IP are you running? The reason I ask is because, in later versions of BIG-IP, you should not have to insert a Content Length header with the compressed payload size on the client-side response. The BIG-IP system takes care of that for you. Is there a separate reason why you are inserting a Content Length header in the iRule?

     

  • TalNe's avatar
    TalNe
    Icon for Nimbostratus rankNimbostratus

    Hi Im the version of f5 is 12.1 The resone is we using external log system with hsl and i need to know the size of the response that we send to the log system after it been gzip

     

  • Hi Talne,

    if the responce content is not

    chunked
    , then you may use the Content-Length header value of the
    HTTP_RESPONSE_RELEASE
    event. Below is a simple iRule which analyses the Content-Length during
    HTTP_RESPONSE
    and
    HTTP_RESPONSE_RELEASE
    event and then performs rocket science to output the compression ratio...

    when HTTP_REQUEST {
        set http_path [HTTP::path] 
    }
    when HTTP_RESPONSE {
        set content_l [HTTP::header value "Content-Length"]
    }
    when HTTP_RESPONSE_RELEASE {
        if { ( [HTTP::header value "Content-Length"] ne "" ) and ( $content_l ne [HTTP::header value "Content-Length"] ) } then {
            log local0.debug "Path: $http_path Comperssion Ratio: [expr { [HTTP::header value "Content-Length"] / ( $content_l / 100 ) }]%"
        }
    }
    

    Note: If you need to analyse the compression ratio of chunked content, then you could experiment with a VIP-targeting-VIP setup where the serverside VIP compresses the content and the clientside VIP analyses the transmited payload of the serverside VIP.

    Cheers, Kai