Server Side Includes
Server Side Includes (let's use the term
SSI from now on) are used in displaying pages served by web
servers on the World Wide Web. They are relatively non-complex
directives that can be inserted into specially marked HTML pages.
SSI directives allow you to retrieve, act upon and display environment
variables and include external files in your HTML pages when
displayed in a browser that can be viewed without the need for
any special programs or plug ins on the web page viewers side.
Before going further, please note that SSI only issues directives;
not commands. SSI is like a macro, script or batch file - it
only causes (directs) other actions to happen. I know, this
is nit picking and you could even argue that SSI 'commands'
other commands, but I think you can see where I'm going with
this. I just felt this needed mention since some people have
an unwarranted fear when the word 'command' is used. Plus, during
this tutorial, I'll be using 'directive' when referring to an
SSI function.
Most of you reading this tutorial are probably already aware
of what SSI means, but for those who don't, the concept is really
quite simple and the name Server Side Includes itself pretty
much describes what SSI does.
Server Side - this is where all the actions take place, on the
web server side of a web page connection.
Includes - after the server side directive completes, the web
server includes the output of that action or the results of
the program specified by the action into an HTML document and
sends the final results to the requesting browser.
With me so far? Even if it's not completely clear, don't worry
too much. After all, you don't have to understand how a CPU
works in order to use a PC. Let's go on and see what SSI can
do.
What Can SSI Do?
If you've ever seen a counter on someone's page that says "You
are visitor #1000" or a personalized greeting that says
"Welcome, visitor from yoursite.com", you have seen
server-side-includes at work. They can be very useful for a
number of different things, and if you've found yourself wanting
to learn more about how to do "cool things" on your
web pages, this tutorial might be what you're looking for.
Listed below are the basic SSI directives that almost all SSI
capable web servers provide and they will probably satisfy the
SSI needs of most people. They are as follows:
exec - directs scripts, programs or even a system command to
execute.
config - configures the format of the SSI error-message, date/time
and file size output strings.
echo - inserts the value returned by an SSI directive into the
web page
include - inserts the content of a specified file into the web
page
flastmod - inserts the date/time stamp of when a specified file
was last updated
fsize - inserts the file size of a specified file into the web
page
There are also eXtended SSI (XSSI) directives available on
some servers which include the ability to perform operations
based on conditions and logic, but the availability of each
directive, the specific parameters/arguments and the syntax
vary from server to server software, so I'll leave covering
those for another tutorial or a future update. If you need information
about XSSI, the best source of information would probably be
the server software documentation.
I tried to keep this page brief because I do go much deeper
into each directive later on in this tutorial, complete with
syntax, the parameters and arguments that can be passed to each
directive, example usage and some examples of results from various
directives, but, hopefully, this is enough to whet your appetite
enough to read on.
For a step by step summary of what happens during an SSI session,
read the How It Works page.
|