[ Team LiB ] |
Server-Side IncludesServer-side includes (SSI) are a wonderful device for saving time and space in web page design.[1] SSI are placeholders that dynamically include data within your page as the server parses the file. Here's the syntax of an SSI command:
The element is a predefined SSI function, like echo, exec, or include, that uses the attribute and value parameters. You can include and change snippets of HTML site-wide with one SSI in each page. You also can add optimized dynamic content with SSI based on time or browser characteristics. That's where XSSI comes in. Conditional SSIWith eXtended Server-Side Includes (XSSI), available in Apache 1.2 and above, Apache added the ability to include conditional logic within your pages, based on environment variables set by the server or within the HTML page itself. Conditional if/else logic adds "flow control" to your pages, allowing you to jazz up your site�with browser-dependent content, randomized links or messages, and timestamps in various formats�and ultimately create modularized pages.[2]
Here is a simple example:
Setting and Testing Environment VariablesThe CGI specification introduced the notion of a standard set of environment variables that are used to communicate between servers and CGI scripts.[3] Environment variables include SERVER_NAME, QUERY_STRING, and CONTENT_LENGTH. In addition, the server sets environment variables based on the headers received from the client, prefixed with the string HTTP_.[4] The HTTP_USER_AGENT string holds information about the client requesting the resource from the server (browser, version, and platform). For example, for Internet Explorer 5.0 on my Macintosh PowerBook, the HTTP_USER_AGENT string looks like this:
You can parse this user agent string to extract information about the client requesting a particular page. Apache extends the standard set of environment variables with their own named variables and gives you the ability to set your own with the set directive.[5]
You can use these variables within the same HTML file or automatically pass them to included HTML files to create nested includes. Here is an example:
To reference variables, you use the dollar sign ($).To use this new isDOM variable, you would write:
Once you've got your variables set up, you can perform comparison operations, like AND (&&) and OR (||). Here is an example:
You can see where this is going: server-side browser sniffing. |
[ Team LiB ] |
No comments:
Post a Comment