15.8 Enabling and Configuring Content Compression

Compressed objects are delivered faster to clients, with fewer round-trips, reducing the overall latency without increasing the investment in expensive hardware.

You can create one or more compression rules specific to each Oracle Traffic Director virtual server, and configure the rules to be applicable either to all requests or to only those requests that match a specified condition.

Note:

Certain files—such as GIF, JPEG, and PNG images; and zipped files—are either already compressed or cannot be compressed any further. Requiring Oracle Traffic Director to compress such files causes additional overhead without providing any compression benefit. Therefore, when creating compression rules for a virtual server, exclude such files.

For each compression rule, you can also specify the following parameters:

  • Compression level, on the scale 1–9. At level 1, the compression time is the least; at level 9, the compression ratio is the best.

    At the higher compression levels, more CPU resources are consumed during the compression process, but relatively less network bandwidth is required to transmit the compressed content. On the other hand, compression at the lower levels is relatively less CPU-intensive, but more bandwidth is required to transmit the resulting content. So when choosing the compression level, consider which resource is more expensive in your environment—CPU resources or network bandwidth.

    • If CPU usage is more expensive, select a lower compression level.

    • If network bandwidth is the primary constraint, select a higher compression level.

  • Number of bytes (fragment size) that should be compressed at a time.

  • Whether the Vary: Accept-Encoding header should be included the response.

    The Vary: Accept-Encoding header instructs proxies situated between the client and Oracle Traffic Director that the compressed content should not be served to clients that cannot decompress the content.

Configuring Compression Rules Using the Administration Console

To create compression rules by using the administration console, do the following:

  1. Log in to the administration console, as described in Section 2.3.2, "Accessing the Administration Console."

  2. Click the Configurations button that is situated at the upper left corner of the page.

    A list of the available configurations is displayed.

  3. Select the configuration for which you want to create compression rules.

  4. In the navigation pane, expand Virtual Servers, expand the name of the virtual server for which you want to create compression rules, and select Compression.

    The Compression Rules page is displayed. It lists the compression rules that are currently defined for the virtual server, and indicates whether the rules are enabled.

    Creating a Compression Rule

    1. Click New Compression Rule.

      The New Compression Rule dialog box is displayed.

      In the Name field, enter a name for the new compression rule.

      Select a compression level from the Compression Level drop-down list.

    2. Click Next.

      If this is the first compression rule for the virtual server, the New Caching Rule dialog box gives you the option to choose whether the rule should be applied to all requests. Select All Requests.

      If you wish to apply the rule to only those requests that satisfy a condition, create a new condition by selecting Create a new condition. In the New Expression pane, select a Variable/Function and an Operator from the respective drop-down lists and provide a value in the Value field.

      Select the and/or operator from the drop-down list when configuring multiple expressions. Similarly, use the Not operator when you want the route to be applied only when the given expression is not true.

      To enter a condition manually, click Cancel and then click Edit Manually. In the Condition field, specify the condition under which the rule should be applied. For information about building condition expressions, click the help button near the Condition field or see "Using Variables, Expressions, and String Interpolation" in the Oracle Traffic Director Configuration Files Reference.

    3. Click Next and then click Create Compression Rule.

      The caching rule that you just created is displayed on the Compression Rules page.

      In addition, the Deployment Pending message is displayed at the top of the main pane. You can either deploy the updated configuration immediately by clicking Deploy Changes, or you can do so later after making further changes as described in Section 4.3, "Deploying a Configuration."

    Editing a Compression Rule

    To enable or disable a compression rule, or to change the settings of a rule, do the following:

    1. Click the Name of the compression rule that you want to change.

      The Edit Compression Rule dialog box is displayed.

      Note:

      To access the condition builder to edit conditions, select Requests satisfying the condition and click Edit. The condition builder enables you to delete old expressions and add new ones.
    2. Specify the parameters that you want to change.

      On-screen help and prompts are provided for all of the parameters.

      When you change the value in a field or tab out of a text field that you changed, the Save button near the upper right corner of the page is enabled.

      At any time, you can discard the changes by clicking the Reset button.

    3. After making the required changes, click Save.

      A message, confirming that the updated configuration was saved, is displayed in the Console Messages pane.

      In addition, the Deployment Pending message is displayed at the top of the main pane. You can either deploy the updated configuration immediately by clicking Deploy Changes, or you can do so later after making further changes as described in Section 4.3, "Deploying a Configuration."

    Deleting a Compression Rule

    To delete a compression rule, click the Delete button. At the confirmation prompt, click OK.

Configuring Compression Rules Using the CLI

  • To create a compression rule for a virtual server, run the create-compression-rule command.

    For example, the following command creates a rule named compress-docs for the virtual server soa.example.com in the configuration soa, to cache the requests for which the expression $uri='^/docs' evaluates to true.

    tadm> create-compression-rule --condition="\$uri='^/docs'" --config=soa --vs=soa.example.com compress-docs
    OTD-70201 Command 'create-compression-rule' ran successfully.
    

    Note that the value of the --condition option should be a regular expression. For information about building condition expressions, see "Using Variables, Expressions, and String Interpolation" in the Oracle Traffic Director Configuration Files Reference.

  • To view a list of the compression rules defined for a virtual server, run the list-compression-rules command, as shown in the following example:

    tadm> list-compression-rules --config=soa --vs=soa --verbose --all
    rule            condition
    -------------------------
    compress-docs   "$uri = '^/docs'
    compress-all    -  
    
  • To view the current settings of a compression rule, run the get-compression-rule-prop command, as shown in the following example:

    tadm> get-compression-rule-prop --config=soa --vs=soa --rule=compress-docs
    fragment-size=8192
    condition="$uri = '^/doc'"
    compression-level=6
    rule=compress-docs
    insert-vary-header=true
    
  • To change a compression rule, run the set-compression-rule-prop command.

    For example, the following command changes the compression level for the rule compress-docs to level 6.

    tadm> set-compression-rule-prop --config=soa --vs=soa.example.com --rule=compress-docs compression-level=9
    OTD-70201 Command 'set-compression-rule-prop' ran successfully.
    
  • To delete a compression rule, run the delete-compression-rule command, as shown in the following example.

    tadm> delete-compression-rule --config=soa --vs=soa.example.com compress-docs
    OTD-70201 Command 'delete-compression-rule' ran successfully.
    

For the updated configuration to take effect, you should deploy it to the Oracle Traffic Director instances by using the deploy-config command.

For more information about the CLI commands mentioned in this section, see the Oracle Traffic Director Command-Line Reference or run the commands with the --help option.