Manual Chapter : Example Using selective compression

Applies To:

Show Versions Show Versions

BIG-IP LTM

  • 13.1.5, 13.1.4, 13.1.3, 13.1.1, 13.1.0

BIG-IP PEM

  • 13.1.5, 13.1.4, 13.1.3, 13.1.1, 13.1.0

BIG-IP ASM

  • 13.1.5, 13.1.4, 13.1.3, 13.1.1, 13.1.0
Manual Chapter

You can create a local traffic policy to support selective compression for types of content that can benefit from compression. For example, common text types (HTML, XML, and CSS style sheets) can realize performance improvements, especially across slow connections, if you compress them.

Examples

Creating a policy to support selective compression: video example

You can associate a BIG-IP® local traffic policy with a virtual server to support selective compression for types of content that can benefit from compression. For example, common text types (HTML, XML, and CSS style sheets) can realize performance improvements, especially across slow connections, if you compress them. Watch the following video for an example of creating a local traffic policy and associating it with a virtual server.

Watch how to create a policy to support selective compression

You can also visit our DevCentral™ YouTube channel to see this video. Use any of these ways:

  • Click this URL: https://youtu.be/d85swKvXS1w.
  • Copy and paste the above URL into your browser window.
  • Use your browser to search for this video using the title F5: Using Selective Compression.

Selective compression: tmsh example

This topic provides a tmsh command to list the configured settings for a Selective Compression policy, for types of content that can benefit from compression. For example, common text types (HTML, XML, and CSS style sheets) can realize performance improvements, especially across slow connections. This topic also provides a tmsh command to list the configured virtual server settings.

(tmos)# list ltm policy SelectiveCompression 
ltm policy SelectiveCompression{
    controls { compression }
    description "This policy compresses specified file types."
    last-modified 2016-03-02:11:46:00
    requires { http }
    rules {
        CompressFiles {
            actions {
                0 {
                    compress
                    response
                    enable
                }
            }
            conditions {
                0 {
                    http-header
                    name Content-Type
                    starts-with
                    values { text/ }
                }
                1 {
                    cpu-usage
                    last-1min
                    less-or-equal
                    values {5}
                }
            }
        }
    }
    status published
    strategy first-match
}

(tmos.ltm.virtual)# list ltm virtual HTTP-VS2
ltm.virtual.HTTP-VS2{
    destination 10.10.0.31:http
    ip-protocol tcp
    mask 255.255.255.255
    policies {
        SelectCompression { }
    }
    profiles {
        http { }
        httpcompression { }
        tcp { }
    }
    source 0.0.0.0/0
    translate-address enabled
    translate-port enabled
    vs-index 3
}

Selective compression: iRules example

This topic provides an example of iRules® code that is equivalent to a policy to support selective compression for types of content that can benefit from compression.

when HTTP_REQUEST {
   COMPRESS::disable
   if { [HTTP::header Content-Type] contains "text" } {
      log "Enabling compression for this request"
      COMPRESS::enable
   }
}