View Source

                                                                                                                                                                                                                                                                                                                                      *Back to [[Book|Administrator's Configuration File Reference#cfr]]     [[Topic|Administrator's Configuration File Reference#chap7]]*
h2. {{Output}}

The {{Output}} stage allows you to select filters that will process outgoing data. For more information, see [{{Output}}|Flow of Control in obj.conf#output].

Every {{Output}} directive has the following optional parameters:

Table 7-73 Output Directive's Optional Parameters
||Optional Parameters ||Description ||
|{{type}} |(Optional) Specifies a wildcard pattern of MIME types for which this function will be executed. |
|{{method}} |(Optional) Specifies a wildcard pattern of HTTP methods for which this function will be executed. Common HTTP methods are {{GET}}, {{HEAD}}, and {{POST}}. |
|{{query}} |(Optional) Specifies a wildcard pattern of query strings for which this function will be executed. |


The following {{Output}}-class filters are described in detail in this section:
* [#{{compress-file}}]
* [#{{http-compression}}]
* [#{{sed-response}}]

In addition, the following common SAFs are valid for the Output directive:
* [{{insert-filter}}|Common SAFs across Multiple Directives#saf1]
* [{{match-browser}}|Common SAFs across Multiple Directives#saf2]
* [{{redirect}}|Common SAFs across Multiple Directives#saf4]
* [{{remove-filter}}|Common SAFs across Multiple Directives#saf5]
* [{{set-variable}}|Common SAFs across Multiple Directives#saf8]

h3. {{compress-file}} {anchor:out1}

For dynamic compression of static files, {{compress-file}} SAF along with {{find-compressed}} SAF is used in Web Server 7.0 Update 4.

When a request is sent to the URI for the first time, the {{compress-file}} function creates a compressed file in the specified subdirectory, provided the file size is between {{min-size}} and {{max-size}}.

If {{check-age}} parameter is set to true, the {{compress-file}} function checks if the available compressed file version is as recent as the non-compressed file version. If not, it recreates a compressed file.

The {{find-compressed}} function checks if the compressed version of the requested file is available. It changes the path and directs to the compressed file under the following conditions:
* A compressed version is available.
* The compressed file version is as recent as the non-compressed version.
* The client supports compression.
* The HTTP method is GET or HEAD.

The following table describes parameter for the {{compress-file}} filter.

Table 7-74 {{compress-file}} Parameter
||Parameter ||Description ||
|{{subdir}} |(Optional) A directory name, relative to the directory in which the original non-compressed file is located. To overwrite a pre-compressed, compressed file lying in docroot, set the {{subdir}} to period ({{.}}). The default value is period ({{.}}), that is, current directory. |
|{{check-age}} |(Optional) Specifies whether to check if the compressed version is older than the non-compressed version. The values can be true or false. The default value is true. |
|{{vary}} |(Optional) The values can be true or false. The default value is true. |
|{{compression-level}} |(Optional) Controls the compression level used by the compression library. The values are from 1 to 9. A value of 1 results in the best speed. A value of 9 results in the best compression. The default value is 6. |
|{{min-size}} |(Optional) The values are from 0 to INT_MAX. The default value is 256. |
| {{max-size}} |Optional) The values are from min-size to INT_MAX. The default value is 1048576 |

h4. Example
{code}
<Objectname="default">
NameTrans fn="assign-name" from="*.html" name="find-compressed"
...
Service method=(GET|HEAD|POST) type=*~magnus-internal/* fn=compress-file
subdir=".compressed-files"
Service method=(GET|HEAD|POST) type=*~magnus-internal/* fn=send-file
...
</Object>

<Objectname="find-compressed">
PathCheck fn="find-compressed"
</Object>
{code}

h4. See Also
* [{{find-compressed}}|PathCheck#path4]
* [#{{http-compression}}]

h3. {{http-compression}} {anchor:out2}

The {{http-compression}} filter compresses outgoing content. If the client does not support compression, or the outgoing content is already compressed, {{http-compression}} performs no action.

Unlike the {{find-compressed}} SAF, the {{http-compression}} filter can compress dynamic content such as the output from SHTML pages, CGI programs, or JSPs. However, for reasons of efficiency, the {{find-compressed}} SAF is better for static content such as non-parsed HTML files. For more information, see [{{find-compressed}}|PathCheck#path4].

h4. Parameters

The following table describes parameter for the {{http-compression}} filter.

Table&nbsp;7-75 {{http-compression}} Parameter
||Parameter ||Description ||
|{{vary}} |Controls whether the filter inserts a {{Vary: Accept-encoding}} header. If {{vary}} is absent, the default value is {{yes}}. {{yes}} tells the filter to insert a {{Vary: Accept-encoding}} header when it compresses content. {{no}} tells the filter to never insert a {{Vary: Accept-encoding}} header. |
|{{fragment-size}} |Size in bytes of the memory fragment used by the compression library to control how much to compress at a time. The default value is 8096. |
|{{compression-level}} |Controls the compression level used by the compression library. Valid values are from 1 to 9. A value of 1 results in the best speed. A value of 9 results in the best compression. The default value is 6. |
|{{window-size}} |Controls an internal parameter of the compression library. Valid values are from 9 to 15. Higher values result in better compression at the expense of memory usage. The default value is 15. |
|{{memory-level}} |Controls how much memory is used by the compression library. Valid values are from 1 to 9. A value of 1 uses the minimum amount of memory but is slow. A value of 9 uses the maximum amount of memory for optimal speed. The default value is 8. |

h4. Example
{code}
Output fn="insert-filter"
type="text/*"
filter="http-compression"
vary="on"
compression-level="9"
{code}

In this example, {code}type="text/*"{code}restricts compression to documents that have a MIME type of {{text}}{{/*}} (for example, {{text/ascii}}, {{text/css}}, {{text/html}}, and so on).

Alternatively, you can specifically exclude browsers that do handle compressed content well by using the {{Client}} tag as follows:
{code}
<Client match="none"\
browser="*MSIE [1-3]*"\
browser="*MSIE [1-5]*Mac*"\
browser="Mozilla/[1-4]*Nav*">
Output fn="insert-filter" filter="http-compression" type="text/*"
</Client>
{code}

This example restricts compression to browsers that are _not_ any of the following:
* Internet Explorer for Windows earlier than version 4
* Internet Explorer for Macintosh earlier than version 6
* Netscape Navigator/Communicator earlier than version 6

Internet Explorer on Windows earlier than version 4 may request compressed data at times, but does not correctly support it. Internet Explorer on Macintosh earlier than version 6 does the same. Netscape Communicator version 4.x requests compression, but only correctly handles compressed HTML. It does not correctly handle linked CSS or JavaScript from the compressed HTML, so administrators often simply prevent their servers from sending any compressed content to that browser (or earlier).

For more information about the {{Client}} tag, see [Client|Objects in obj.conf#conf61].

h3. {{sed-response}} {anchor:out3}

The {{sed-response}} filter applies {{sed}} edit commands to an outgoing response entity body, for example, an HTML file or output from a Servlet.

h4. Parameter

The following table describes parameter for the {{sed-response}} filter

Table&nbsp;7-76 {{sed-response}} Parameter
||Parameter ||Description ||
|{{sed}} |Specifies a {{sed}} command script. When multiple {{sed}} parameters are provided, the {{sed}} edit commands are evaluated in the order they appear. |

h4. Example

The following {{obj.conf}} code instructs {{sed-response}} to rewrite any occurrence of {{http://127.0.0.1/}} in an HTML response to {{http://server.example.com/}}:
{code}
Output fn="insert-filter"
type="text/html"
filter="sed-response"
sed="s|http://127.0.0.1/|http://server.example.com/|g"
{code}

h4. See Also
* [{{insert-filter}}|Common SAFs across Multiple Directives#saf1]
* [{{sed-request}}|Input#inp1]

The individuals who post here are part of the extended Sun Microsystems community and they might not be employed or in any way formally affiliated with Sun Microsystems. The opinions expressed here are their own, are not necessarily reviewed in advance by anyone but the individual authors, and neither Sun nor any other party necessarily agrees with them.

Copyright 1994-2009 Sun Microsystems, Inc.
Powered by Atlassian Confluence
Sun Guidelines on Public Discourse Privacy Policy Terms of Use Trademarks Site Map Employment Investor Relations Contact