A page that uses SSI involves some processing on the server's side before the server sends the file across the Net to the browser |
ONLINE, July 2000 As the Web becomes more ensconced in libraries of all types, issues of Web site design and maintenance become increasingly important. Even for searchers, knowledge of some of the current issues, techniques, and approaches to Web design can aid the searcher in understanding a Web site and its organization. There are now many new tools for the Web builder--Cascading Style Sheets, JavaScript, ASP, PHP, CGI, and a host of other acronyms and specialized programs. As sites grow, designers look for short cuts to providing common elements on all of a site's pages--or at least on one section of the site. Some of these tools can simplify the task of maintaining a Web site. One of these tools is Server Side Includes, or SSI. Almost as old as HTML, SSI has been available for some time. Not all sites use it or even have it enabled, but its use and the use of similar technologies have been growing. THE HTML TRADITIONThe basic underlying language of Web pages, and the acronym with which most Web builders begin, is HTML, the hypertext markup language. HTML is the language that identifies structural elements on Web pages such as the title, paragraphs, tables, list items, and many others.HTML works great for creating basic Web pages, one page at a time. It is where most people start when creating a Web site. But moving beyond HTML to use tools such as SSI provides opportunities for adding dates and file names, making elements common across the site, and pulling in additional files onto a page. SERVER SIDE INCLUDESThe function of Server Side Includes is to have the Web server do something with the file. A static HTML page is simply sent from the Web server to the Web browser program, which figures out how to display the HTML codes and the content within them. A page that uses SSI involves some processing on the server's side (thus the name) before the server sends the file across the Net to the browser.For example, Server Side Includes can add content to a Web page such as the current date or time, the URL of the page, the directory in which the file is located, the kind of browser the user has, or pull in content from separate files to construct the page before it is delivered.
Let's look at some examples. One basic starting point is to use code such as These codes are not displayed or even sent to the browser. When a user clicks on a link, a message gets sent to the Web server. The Web server then scans the Web page for any SSI codes and processes them. Then the Web server sends the resulting file to the Web browser. For this reason, a user cannot tell whether a specific page is using SSI or not. Looking at the underlying HTML code only shows the post-processed document. Selected SSI Echo Commands
THE ECHO COMMANDThese examples use the SSI echo command. The echo function is one of several SSI capabilities. There are several variables and pieces of information that the echo command can add to a Web page. The Table outlines several of the more popular echo commands along with a brief description of their output.
The full syntax for using each echo command is shown in the table. It always starts with
The date commands can be configured to report the dates in a wide variety of formats. Be wary of the various date commands. While ADDING COMMON ELEMENTSOne powerful function of SSI is to add the same header, footer, or other navigational page consistently throughout the site. The SSI include command accomplishes this objective. There are two include commands. To add files located in the same directory, use the file instruction:<!--#include file="side.shtml" --> . This adds the file named side.shtml at the exact point in the page where the SSI command is located. To pull in a file located in another directory, use the virtual include <!--#include virtual="/subdir/top.shtml" --> .The include commands help make it much easier to have the same header or sidebar on all pages on a site. Using includes to add the surrounding content also makes for a less complex template file. The great advantage for using SSI for the common parts of a Web page is when that portion needs to change, the modifications can be made to just one file. Then the header or sidebar on each page on the site will reflect that change immediately. SSI DIFFICULTIESUnfortunately, SSIs are not enabled on all Web servers. A server administrator may not enable SSI due to concerns about increased server load or security. Using SSI does put a slight increase on the load on the server. The echo and includes add very little extra load, but the exec or other SSI functions that invoke a whole program or CGI script can be more server-intensive. In addition, the exec command can pose security risks if the server is not well protected and carefully managed.In addition, even if they are enabled, SSIs may require the special file extension of .shtml. Some system administrators may be convinced to enable SSI for all .html files as well as .shtml ones, but that depends on their preferences. Since file names that end with .shtml are not as common as .html, that may be another disincentive to using them. One other problem with SSIs is that use of them can create problems for reporting the accurate date of the file to search engines and via a browser's document information command. Since the file is processed by the server at the time it is requested, the date stamp may either not be transmitted or not properly reported. In addition, when a page uses an include to add content and the other file has updated content, the date on that page may be older than the content itself. GETTING STARTED WITH SSIThere are many SSI commands and functions available, and more advanced usage can get extremely complex. Yet the echo and include commands are relatively simple to implement. For those interested in more detailed explanations and lists of functions, there are many resources available.Most Web servers include documentation that has a section about SSI, although server documentation often does not provide the most easily understood explanation. There are plenty of general Web sites that offer more details about SSI including lists and formats of the commands. For one example of a good overview site, see http://bignosebird.com/ssi.shtml (note that that page probably uses SSI since it has the .shtml extension). More advanced uses of SSI can involve other programs or scripts. For example, an SSI could pull in JavaScript, CGI, or similar scripts. Advanced SSI capabilities include nested instructions, eXtended SSI (XSSI), exec, and virtual. The virtual command can do most of what exec can do but with less security risk. In deciding whether to use SSI or not, it can be helpful to know that SSI is not the only option for adding such content and functions to a Web site. Other technologies such as CGI, PHP, and ASP can handle similar functions and may be more appropriate depending on local circumstances. THE SEARCHER'S PERSPECTIVEWhile SSI can be very helpful to the Web designer and site builder, what is its significance for the searcher? Understanding the publication pattern and tools of the Web can help in understanding the documents, the organization of sites, and some of the errors that may occur. Knowing about SSI can also help in explaining why some pages are .shtml as opposed to the more common .html.If you come across a page that seems to have a missing section, it could be a malfunctioning SSI. Other pages may display the actual SSI code rather than the resulting output, which is another sign of an improper or malfunctioning SSI. The displayed dates on Web pages are one example. Knowing that a Web page can be displaying today's date even when none of the main content has changed helps in interpreting and evaluating that page. The include command can cause the opposite problem. With SSI reporting the date the page was last modified, another SSI could be adding a separate file that has been updated more recently. Beyond just information for searchers, understanding the basics of SSI can be useful for anyone that adds content to a Web site. By using includes, a simple text file can contain the content, and people with no HTML experience can be given access to change that text. While there are many other ways to add content to sites, some creative uses of SSI can offer such content solutions, even on the low-budget Web site. Server Side Includes offers many advantages in Web site design. Their ability to include files and to report dates, file names, and referrers can be put to many uses. Even for those who choose not to use SSI, a basic knowledge of its capabilities helps in understanding how other sites are structured, and how information may be added to a page. Greg R. Notess (greg@notess.com; http://www.notess.com/) is a Reference Librarian at Montana State University. Comments? Email letters to the Editor at editor@infotoday.com. |
[infotoday.com] | [ONLINE] | [Current Issue] | [Subscriptions] | [Top] |
Copyright © 2000, Information Today, Inc. All rights reserved.
Comments