The Output stage allows you to select filters that will process outgoing data. For more information, see Output.
Every Output directive has the following optional parameters:
Table 7–73 Output Directive's Optional Parameters
Optional Parameters |
Description |
---|---|
(Optional) Specifies a wildcard pattern of MIME types for which this function will be executed. |
|
(Optional) Specifies a wildcard pattern of HTTP methods for which this function will be executed. Common HTTP methods are GET, HEAD, and POST. |
|
(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:
In addition, the following common SAFs are valid for the Output directive:
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 |
<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>
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.
The following table describes parameter for the http-compression filter.
Table 7–75 http-compression Parameter
Parameter |
Description |
---|---|
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. |
|
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. |
|
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. |
|
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. |
|
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. |
Output fn="insert-filter" type="text/*" filter="http-compression" vary="on" compression-level="9"
In this example, type="text/*" 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:
<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>
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 JavaScriptTM 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.
The sed-response filter applies sed edit commands to an outgoing response entity body, for example, an HTML file or output from a Servlet.
The following table describes parameter for the sed-response filter
Table 7–76 sed-response Parameter
Parameter |
Description |
---|---|
Specifies a sed command script. When multiple sed parameters are provided, the sed edit commands are evaluated in the order they appear. |
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/:
Output fn="insert-filter" type="text/html" filter="sed-response" sed="s|http://127.0.0.1/|http://server.example.com/|g"