ssi

The 'ssi' directive enables or disables the server-side includes feature within specified contexts.

Syntaxssi on | off;
Defaultoff
Contexthttp, server, location, if in location
Argumentsflag

Description

The 'ssi' directive, part of the NGINX HTTP Core module, controls the use of Server Side Includes (SSI), allowing dynamic content generation by embedding server-side directives within HTML files. This feature is primarily useful for including common header and footer templates, inserting dynamic content, and other scenarios where content needs to be shared across pages without static duplication. The directive takes a flag as an argument, which can enable (on) or disable (off) SSI functionality in HTTP, server, and location contexts.

When SSI is enabled, NGINX processes files containing SSI directives, interpreting them when serving the files. For instance, directives like <!--#include virtual="header.html" --> can be used within an HTML document to include the content of the specified file. It is essential to ensure that the files with SSI directives are served with a media type that supports SSI, such as text/html, to function correctly. If SSI is not configured properly, NGINX will serve the raw content without interpreting any directives, which can lead to confusion and unexpected output.

Furthermore, it's worth noting that enabling SSI can have performance implications since it adds overhead to the request processing. To optimize performance, SSI should be used judiciously in high-traffic scenarios, and caching aspects should be considered to mitigate the additional load introduced by processing SSI instructions.

Config Example

location / {
    ssi on;
    ssi_silently on;
    root /usr/share/nginx/html;
    index index.html;
}

Ensure that the ssi directive is used in a context where it is allowed, such as http, server, or location.

Files served with SSI directives must have a text/html content type to be processed correctly.

Using SSI in high-traffic sites can lead to performance issues; caching strategies may be necessary.

← Back to all directives