Server_Side_Includes

Server Side Includes

Server Side Includes

Interpreted server-side scripting language


Server Side Includes (SSI) is a simple interpreted server-side scripting language used almost exclusively for the World Wide Web. It is most useful for including the contents of one or more files into a web page on a web server (see below), using its #include directive. This could commonly be a common piece of code throughout a site, such as a page header, a page footer and a navigation menu. SSI also contains control directives for conditional features and directives for calling external programs. It is supported by Apache, LiteSpeed, nginx, IIS as well as W3C's Jigsaw.[1] It has its roots in NCSA HTTPd.[2]

In order for a web server to recognize an SSI-enabled HTML file and therefore carry out these instructions, either the filename should end with a special extension, by default .sdoc, .stm, .shtm, or, if the server is configured to allow this, set the execution bit of the file.[3]

Design

As a simple programming language, SSI supports only one type: text. Its control flow is rather simple, choice is supported, but loops are not natively supported and can only be done by recursion using include or using HTTP redirect.[lower-alpha 1] The simple design of the language makes it easier to learn and use than most server-side scripting languages, while complicated server-side processing is often done with one of the more feature-rich programming languages. SSI is Turing complete.[4]

SSI has a simple syntax: <!--#directive parameter=value parameter=value -->. Directives are placed in HTML comments so that if SSI is not enabled, users will not see the SSI directives on the page, unless they look at its source. Note that the syntax does not allow spaces between the leading "<!--" and the directive. Apache tutorial on SSI stipulates the format requires a space character before the "-->" that closes the element.[5]

Examples

A web page containing a daily quotation could include the quotation by placing the following code into the file of the web page:

<!--#include virtual="../quote.txt" -->

With one change of the quote.txt file, all pages that include the file will display the latest daily quotation. The inclusion is not limited to files, and may also be the text output from a program, or the value of a system variable such as the current time.

Directives

Common

The following are SSI directives from the times of NCSA HTTPd (the 1990s).[2] Some implementations do not support all of them.[6]

More information Directive, Parameters ...

Control directives

Control directives are later added to SSI. They include the ubiquitous if-elif-else-endif flow control and variable writing as well as more exotic features like loops only found in some implementations.

More information Directive, Parameters ...

See also

Notes

  1. Nevertheless found in some implementations, including Jigsaw.

References

  1. "SSI Commands". W3C. Retrieved 24 March 2019.
  2. "Server Side Includes (SSI)". NCSA HTTPd Tutorial. Archived from the original on 3 March 1997. Retrieved 24 March 2019.
  3. "Configuring your server to permit SSI". Apache Tutorial: Introduction to Server Side Includes. The Apache Software Foundation. Retrieved 24 June 2015.
  4. "Server Side Includes Turing machine, Jan Schejbal". Janschejbal.de. Retrieved 2012-12-06.
  5. "Basic SSI Directives and Syntax". 2018-02-09. Retrieved 2018-02-09.
  6. "Module ngx_http_ssi_module". nginx documentation. Retrieved 16 November 2021.
  7. "Apache Module mod_include". Apache HTTP Server Version 2.4 Documentation. Apache Software Foundation. Retrieved 2021-09-07.
  8. "mod_include". Apache HTTP Server. Retrieved 25 March 2019.
  9. "ngx_http_ssi_module". nginx.org. Retrieved 25 March 2019.

Share this article:

This article uses material from the Wikipedia article Server_Side_Includes, and is written by contributors. Text is available under a CC BY-SA 4.0 International License; additional terms may apply. Images, videos and audio are available under their respective licenses.