Server Side Includes (SSI)
|Server Side Includes allow you to integrate dynamic content into your web pages. SSIs allow you to execute a CGI program from your page or simply include the contents of a text file. All OLI servers allow SSIs. The ‘ SS ‘ stands for Server-Side and the ‘ I ‘ stands for whatever your consultant tells you. ‘Includes’ and ‘interface’ are both popular. (SPML — Server Parsed Markup Language — is also used to refer to the code you write. Really, you can learn the entire small command set SSI provides before you learn the acronyms.) Basically, SSI is a mechanism whereby you can have our server do something to your HTML before sending it to the browser. SSI does some of the same things CGI does. Some differences are that SSI doesn’t handle forms but CGI is much more involved if you just want another file or the output of a program included in your document. Used properly, the SSI can help make your pages more responsive and can even help make maintaining your site an easier task. Put simply, SSI is sort of like using your HTML server as a cut and paste editor. Here is basically what happens when your server handles a request for an SSI document.
1) The server reads the document and parses (looks for special instructions) it for directives. (directions)
Closer Look (examples):
Now that the renaming issue is put behind, let’s look at what SSI can do and some reasons why you would use it on your pages. Here are some of the most useful tasks you can do with SSI:
1) Display the last modified date of a web page
Displaying the last modified date of a web page:
<!--#flastmod file="ssi.shtml" -->
Displaying the current date and time:
<!--#echo var="DATE_LOCAL" -->
The result would be:
CODE USE OF CODE
There are many ways to customize the format of the date output.
Including a document inside another:
The SSI code for this is:
Put this code anywhere in your webpage, and test.htm will show up in it’s place. Notice that the file does not have to be a “.htm” or “.html” file. The included file could also be a “.txt” file. You might ask what use would this have on your web site. Here’s an example. Let’s say you have some content that is repeated on many pages of your site like your contct information or even a menu bar. If you save that common content as an individual html or text file, and if you use SSI instead to include that content onto those pages, updating your contact information or adding items to your menu will become as easy as changing just that ONE file. Now, if you didn’t use SSI to include that content, you would have to change EVERY single page the content appears on.
Executing a CGI script or command directly from a web page:
Notice that you only use this command when the CGI script requires the use of SSI to function.