Odilon Redon's smiling spider SSI

Server Side Includes (SSI) on UNHINFO:
Discussion and Demonstrations.
author: jim.cerny@unh.edu

Internet: Server Side Includes

Aug 17, 1999, 1:30-3:30 p.m., Hewitt Annex 2.

Description: Server Side Includes (SSI) Usage. Shows how to direct the UNHINFO server (Apache) to include information automatically in your Web pages. Common usage is to include headers, footers, URLs, and last-modified dates. Lecture/demo format. Instructor: Jim Cerny.

Prerequisite: Basic HTML authoring.
Sign-up via CIS Training Web page.

Overview.

Server Side Includes (SSI) are a way to promote modular design of your documents and to produce simple dynamic documents. Modular design allows you to separate selected content so that a change made in one place (e.g., a header or footer) is applied to all the files in a collection. SSI in combination with Cascading Style Sheets holds the promise for very effective modular design. Dynamic content is the inclusion of information based on the document context at the time it is served (e.g., to include a modification date or to present content based on browser characteristics).

For a Web server that supports SSI, such as Apache with more than 55% of the servers in Internet use, the server sysadmin enables SSI. Then the page author is free to embed SSI directives (commands) in their pages using HTML comments. The Web server scans these HTML files (.html, .htm, .shtml) and parses and acts on any SSI directives before sending the page to the browser.

Syntax.

SSI directives have the basic form of an HTML comment statement containing the command keywords, attribute (argument) keywords, and attribute values:

   <!--#command attribute="value" attribute="value" -->
Be very careful of the details. HTML comments begin with "<!--" and then without any whitespace there is an "#" and the command name of the directive. There may be one or more attributes, as applicable to the command, and these may be set to values, with the values in quotes. Then there is the end of the comment "-->" and that may be preceded by white space. Several of these comments may be put on one line, as is allowed with HTML.

Mini-FAQ.

  • Is SSI a standard?
    Though widely used, SSI is not a formal RFC or other standard. SSI was originally developed and documented for the NCSA Web server, then included and extended in the widely-used Apache Web server.

  • What do Web authors do?
    Web authors place SSI directives in their pages as commands embedded in HTML comment statements.

  • What does the server do?
    The Web server (Apache) parses the HTML file and acts on any SSI directives it finds before sending the file (page) to the browser.

  • What does the browser do?
    The browser (Netscape, MSIE, Lynx) displays it as any other Web page and has no way to know that SSI was involved.

  • Any special file types?
    The file type ".shtml" is added as a new, optional file type for SSI Web pages in addition to support for the standard ".html" and ".htm" file types.

  • What are the available SSI directives?
    The directives are:
      config, echo, flastmod, fsize, include, printenv,
      set, if-elif-else-endif
    
    On UNHINFO the "exec" directive is disabled.

  • What do SSI error messages look like?
    The standard text is:
    [an error occurred while processing this directive]

  • Is there any downside to using SSI?
    It requires a little bit of work to learn the syntax and to plan how to effectively use SSI with your pages. In the worst case you might design your pages for SSI use and then someday wish to move them to a server with more limited or different SSI support (either by technical design or by site policy). For example, Microsoft's Internet Information Server (IIS), with more than 20% of the servers in Internet use, only supports the "include" directive in their Active Server Page (ASP) technology. And StarNine's WebStar Server for Macintoshes, with about 1% of the servers in Internet use, includes the WebStar SSI plug-in for support that is extensive but not identical to Apache.

  • Are there any issues for virtual hosts on UNHINFO?
    Only one very minor issue: if you try to reference an include file in the SSI Library on UNHINFO, it will fail. The solution is to include files from your own directory(s).

  • How do I determine which software my Web server is using?
    If you know the URL for the server, use Netcraft's "What's that site running?" service.

Discussion Examples.

More Reading.

The following materials are listed from the more general and introductory to the more specific and advanced. Please consider two things when reading these materials: (1) Some documents include information for the Apache Web server sysadmin as well as information for page authors. (2) Some documents describe features that may not be available on the UNHINFO Web server (e.g., the SSI "exec" directive).

[an error occurred while processing this directive]