Forum Discussion

Tony_Hobson_189's avatar
Tony_Hobson_189
Icon for Nimbostratus rankNimbostratus
Mar 22, 2017

Understanding STREAM expression and Compression

Hello - I have a question to try and confirm my understanding around using STREAM and compression.

I'm aware of the need to disable compression so STREAM is able to inspect the payload, but after the STREAM expression has done it's replacing, is or can, the content be compressed to improve performance or is this lost?

In our set-up, we have physical LTMs that handle SSL offloading (part of the cloud solution we use) and virtual LTMs that we configure for service specific iRules etc.

So on the physical LTM with SSL offload, there is STREAM (blank) and iRule to replace http:// with https:// on the response with the following:

when HTTP_REQUEST {
     PHYSICAL LTM WITH SSL OFFLOAD
     tell server not to compress response
    HTTP::header remove Accept-Encoding

     disable STREAM for request flow
    STREAM::disable
}
when HTTP_RESPONSE {
     catch and replace redirect headers
    if { [HTTP::header exists Location] } {
        HTTP::header replace Location [string map {"http://" "https://"} [HTTP::header Location]]
    }

     only look at text data
    if { [HTTP::header Content-Type] contains "text" } {

         create a STREAM expression to replace any http:// with https://
        STREAM::expression {@http://@https://@}

         enable STREAM
        STREAM::enable
    }
}

On the virtual LTM, we have a similar entry in the iRule:

when HTTP_REQUEST {
     VIRTUAL LTM
     tell server not to compress response
    HTTP::header remove Accept-Encoding

     disable STREAM for request flow
    STREAM::disable
}
when HTTP_RESPONSE {
     catch and replace redirect headers
    if { [HTTP::header exists Location] } {
        HTTP::header replace Location [string map {"://internal.url" "://external.url"} [HTTP::header Location]]
    }

     only look at text data
    if { [HTTP::header Content-Type] contains "text" } {

         create a STREAM expression to replace any http:// with https://
        STREAM::expression {@://internal.url@://external.url@}

         enable STREAM
        STREAM::enable
    }
}

So in this set-up, we we loose the benefit of HTTP compression?

Thanks

  • kunjan's avatar
    kunjan
    Icon for Nimbostratus rankNimbostratus

    You should be able to attach the compression profile and can remove the 'HTTP::header remove Accept-Encoding' from the iRule

    https://support.f5.com/csp/article/K15434

    "When you configure an HTTP Compression profile and assign it to a virtual server, the BIG-IP system reads the Accept-Encoding header of a client request and determines what content encoding method the client prefers. The BIG-IP system then removes the Accept-Encoding header from the request and passes the request to the server. Upon receiving the server response, the BIG-IP system inserts the Content-Encoding header, specifying either the gzip or deflate based on the compression method that the client specifies in the Accept-Encoding header."