Sun Java System Web Server 6.1 SP12 Administrator's Guide

Configuring the Server for Content Compression

Sun Java System Web Server 6.1 supports HTTP content compression. Content compression allows you to increase delivery speed to clients and serve higher content volumes without increasing your hardware expenses. Content compression reduces content download time, a benefit most apparent to users of dialup and high-traffic connections.

With content compression, your Web server sends out compressed data and instructs the browser to decompress the data on the fly, thus reducing the amount of data sent and increasing page display speed.

You can configure your server in two ways to handle compressed data:

For information on enhancing the server’s compression-handling capabilities, see Compression-related Changes in obj.conf.

Configuring the Server to Serve Precompressed Content

You can configure Sun Java System Web Server to generate and store pre-compressed versions of files in a specified directory. When configured, and only if an Accept-encoding: gzip header is received, all requests for files from a directory configured to serve precompressed content are redirected to requests for an equivalent compressed file from that directory if such a file exists. For example, if the Web server receives a request for myfile.html, and both myfile.html and myfile.html.gz exist, then those requests with an appropriate Accept-encoding header receive the compressed file.

To configure your server to serve precompressed content, perform the following steps.

ProcedureTo configure your server to serve precompressed content

  1. From the Class Manager, click the Content Management tab.

  2. Click Serve Precompressed Content.

  3. Enter the following information:

    • Editing. Select the resource from where precompressed content will be served from the drop-down list. If you choose a directory, the server will serve precompressed content only when the server receives a URL for that directory or any file in that directory.

      Click the Browse button to browse the primary document directory, or click the Wildcard button to specify a wildcard pattern. For information on using wildcard patterns, see Wildcards Used in the Resource Picker.

      • Activate Serving Precompressed Content? Allows you to instruct the server to serve precompressed content for the selected resource.

      • Check Age. Specify whether to check if the compressed version is older than the non-compressed version. Possible values are yes and no.

        If set to yes, then the compressed version, if it is older than the non-compressed version, will not be selected.

        If set to no, then the compressed version, even if it is older than the non-compressed version, will always be selected.

        By default, the value is set to yes.

      • Vary Header. Specifies whether to use a Vary: Accept-encoding header. Select either yes or no.

        If set to yes, then a Vary: Accept-encoding header is always inserted when a compressed version of a file is selected.

        If set to no, then a Vary: Accept-encoding header is never inserted.

        By default, the value is set to yes.

  4. Click OK.

Configuring the Server to Compress Content on Demand

You can also configure the Sun Java System Web Server 6.1 to compresses transmission data on the fly. A dynamically generated HTML page doesn’t exist until a user asks for it. This is particularly useful for e-commerce-based Web applications and database-driven sites.

To configure your server to compress content on demand, perform the following steps.

ProcedureTo configure your server to compress content on demand

  1. From the Class Manager, click the Content Management tab.

  2. Click Compress Content on Demand.

  3. Enter the following information:

    • Editing. Select the resource from where compressed content will be served dynamically on demand from the drop-down list. If you choose a directory, the server will serve compressed content only when the server receives a URL for that directory or any file in that directory.

      Click the Browse button to browse the primary document directory, or click the Wildcard button to specify a wildcard pattern. For information on using wildcard patterns, see Wildcards Used in the Resource Picker.

      • Activate Compress Content on Demand? Choose whether the server should serve precompressed content for the selected resource.

      • Vary Header. Specify whether to insert a Vary: Accept-encoding header. Select either yes or no.

        If set to yes, then a Vary: Accept-encoding header is always inserted when a compressed version of a file is selected.

        If set to no, then a Vary: Accept-encoding header is never inserted.

        By default, the value is set to yes.

      • Fragment Size. Specifies the memory fragment size in bytes to be used by the compression library (zlib) to control how much to compress at a time. The default value is 8096.

      • Compression Level. Specifies the level of compression. Choose a value between 1 and 9. The value 1 yields the best speed; the value 9 the best compression. The default value is 6, a compromise between speed and compression.

  4. Click OK.

Compression-related Changes in obj.conf

When compression is enabled in the server, an entry gets added to the obj.conf file. A sample entry is shown below:

Output fn=”insert-filter” filter=”http-compression” type=”text/*”

To restrict compression to documents of a particular type only, or to exclude browsers that don’t work well with compressed content, you would need to edit the obj.conf file. For more information on what you need to do to accomplish this, see the Sun Java System Web Server 6.1 SP12 NSAPI Programmer’s Guide.