Module directives and variables

Having directives inserted within the actual content of files that Nginx serves raises one major issue: What files should Nginx parse for SSI commands? It would be a waste of resources to parse binary files, such as images (.gif, .jpg, .png) or other kinds of media, since they are unlikely to contain any SSI commands. You need to make sure to configure Nginx correctly with the directives introduced by this module:

Directive

Description

ssi

Context: http, server, location, if

Enables parsing files for SSI commands. Nginx only parses files corresponding to MIME types selected with the ssi_types directive.

Syntax: on or off

Default value: off

ssi on;   

ssi_types

Context: http, server, location

Defines the MIME file types that should be eligible for SSI parsing. The text/html type is always included.

Syntax:

ssi_types type1   [type2] [type3...];   
ssi_types *;   

Default value: text/html

ssi_types   text/plain;   

ssi_silent_errors

Context: http, server, location

Some SSI commands may generate errors; when that is the case, Nginx outputs a message at the location of the command: An error occurred while processing the directive. Enabling this option silences Nginx, and the message does not appear.

Syntax: on or off

Default value: off

ssi_silent_errors   off;   

ssi_value_length

Context: http, server, location

SSI commands have arguments that accept a value (for example, <!--# include file="value" -->). This parameter defines the maximum length accepted by Nginx.

Syntax: Numeric

Default: 256 (characters)

ssi_value_length   256;   

ssi_ignore_recycled_buffers

Context: http, server, location

When set to on, this directive prevents Nginx from making use of recycled buffers.

Syntax: on or off

Default: off

ssi_min_file_chunk

Context: http, server, location

If the size of a buffer is greater than ssi_min_file_chunk, data is stored in a file and then sent via sendfile. In other cases, it is transmitted directly from the memory.

Syntax: Numeric value (size)

Default: 1,024

ssi_last_modified

Context: http, server, location

If set to off, Nginx removes the Last-modified header from the original response during SSI processing in order to increase caching likeliness. The Last-modified date is likely to change often, due to dynamically generated elements contained in the response, rendering it non-cacheable.

Syntax: on or off

Default: off

 

A quick note regarding possible concerns about the SSI engine resource usage: by enabling the SSI module at the location or server block level, you enable parsing of at least all text/html files (pretty much any page to be displayed by the client browser). While the Nginx SSI module is efficiently optimized, you might want to disable parsing for files that do not require it.

Firstly, all your pages containing SSI commands should have the .shtml (Server HTML) extension. Then, in your configuration, at the location block level, enable the SSI engine under a specific condition. The name of the served file must end with .shtml:

server { 
    server_name website.com; 
    location ~* .shtml$ { 
        ssi on; 
    } 
}

On one hand, all HTTP requests submitted to Nginx will go through an additional regular expression pattern matching. On the other hand, static HTML files or files to be processed by other interpreters (.php, for instance) will not be parsed unnecessarily.

Finally, the SSI module enables two variables:

  • $date_local: Returns the current time, according to the current system time zone
  • $date_gmt: Returns the current GMT time, regardless of the server time zone
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.117.171.134