1st Singapore Web Hosting
> Web Site Hosting
What Can Server Side Includes (SSI) Do For You?
You may have noticed as you browse this site, that
our pages end with shtml extension instead of the more
familiar html or htm. This is because we use Server Side Includes
(SSI for short). Used properly, SSI can help make your web
responsive and can even help make maintaining your site
a much easier task.
Simply put, SSI directives in a shtml page will
call another file (which can be text file or a program) and merger
(include) the result in the finished page sent to browser. In
other words, SSI will include or copy files into a web page. Think of
it as being sort of like a document merge in word processing.
example will make it clearer.
Take a look at the
top menu on this page. In the actual source shtml code, there's no
visible text at that place. Instead, I use this line of SSI
In the header.txt file, which is a
simple unformatted text file created by Notepad, I write these
html code just like in any other normal html pages:
<a href="../index.shtml">Home</a> |
<a href="index.shtml">Web Hosting</a> |
<a href="../webdesign/index.shtml">Web Design</a> |
<a href="../promotion/index.shtml">Web Site Promotion</a> |
<a href="../livehelp/index.shtml">Live Help Service</a> |
<a href="../faq/index.shtml">FAQ</a> |
your browser requested this page, our
server first parsed the shtml file, then processed the SSI
directive line (called the header.txt file), merged what's in
header.txt into the final page, then sent it to your browser. So,
instead of seeing the SSI directive, you see a normal top menu
retrieved from the header.txt
But if you "view
source" of this page, you won't see the SSI directive at all
since the server has processed it before sending it to you.
look at the menu at left side, at the bottom, even the newsletter
subscription form, they're all created by SSI. The reason? It
makes web site maintenance much easier.
do much more than that. Here're some examples.
Display Local Time With Server Side
The ECHO directive allows you to include information from the environment
in your pages. For example, date and time.
This is something that you have probably seen on quite a few
This offer is going to be expired at midnight of Monday September 16 2019.
Order It Now!
You don't think the webmaster is updating the page everyday, do
The following little snippet of source code is all you need to add this feature to your page:
This offer is going to be expired at midnight
of <b><!--#config timefmt="%A %B %d %Y" -->
<!--#echo var="DATE_LOCAL" --></b>.
The ECHO directive DATE_LOCAL displays the local
time of where your server is - US for this web site. The CONFIG
command adjusts the time format.
Similarly, DATE_GMT will show Greenwich time.
Making A Real Back Button
Here is a cute server side includes trick, a back button that actually takes you back to where you came from.
BACK BUTTON (Remember to press
forward and come back here;-)!
How did the page know where you came from. Remember,
SSI can bring in server environment information and one tidbit at our disposal is HTTP_REFERER. This is the URL that brought you to this page. Here is the source code for this trick:
<A HREF="<!--#echo var="HTTP_REFERER"-->">BACK BUTTON</A>
If you came to this page directly such as from
bookmark, then (none) would be the value for HTTP_REFERER.
Here are some of other values ECHO directive can
CONTENT_LENGTH - size of input posted from client
CONTENT_TYPE - MIME type of content
DOCUMENT_NAME - document name that was requested
DOCUMENT_URI - URL of the document
LAST_MODIFIED - document modified date
PAGE_COUNT - number of accesses to current document since server was brought on line
REMOTE_ADDR - IP address of the client
REQUEST_METHOD - HTTP method: GET OR POST
SERVER_NAME - server hostname
SERVER_SOFTWARE - name of the server software
TOTAL_HITS - total pages served by server since brought on line
You're visiting this page from IP 18.104.22.168, right?
Another great thing about server side includes is the ability to either run programs as straight system executions, or as CGI Scripts. For security reasons,
only use them if you know what you're doing.
As you can see, SSI is a very useful tools for
webmasters. However, sometimes you may need to take another thing into
consideration - performance. When a regular HTML page is requested, the server only has to handle sending that page to the
browser requesting it. With SSI, the server must first read the SHTML file, process any directives (which can be program output or files to be
included in) and then deliver the assembled page to the browser.
If you are expecting thousands of hits per minute,
that can be a lot of extra work for the server. On the other hand, keeping your pages trim will more than make up for the SSI performance
cost in most cases.
Today, horsepower is cheap and getting cheaper. If
your hosting service provider does not allow SSI because it may
slowdown their server significantly, you can be sure they're not
Feel free to use this article in your
publication or web site.
It's pre-licensed to you.
The only requirement is to include this resource box:
Article by Zac Hewlett at
web site design and promotion articles, proven online
marketing tips and techniques.
More Web Site Hosting Articles