Questions tagged [server-side-includes]

Server Side Includes (SSI) is a simple interpreted server-side scripting language used almost exclusively for the Web.

The most frequent use of SSI is to include the contents of one or more files into a web page on a web server. For example, a web page containing a daily quotation could include the quotation by placing the following code into the file of the web page:

<!--#include virtual="../quote.txt" -->

With one change of the quote.txt file, all pages including the file will display the latest daily quotation. The inclusion is not limited to files, and may also be the text output from a program, or the value of a system variable such as the current time.

Server Side Includes are useful for including a common piece of code throughout a site, such as a page header, a page footer and a navigation menu. Conditional navigation menus can be conditionally included using control directives.

In order for a web server to recognize an SSI-enabled HTML file and therefore carry out these instructions, either the filename should end with a special extension, by default .shtml, .stm, .shtm, or, if the server is configured to allow this, set the execution bit of the file.

As a simple programming language, SSI supports only one type: text. Its control flow is rather simple, choice is supported, but loops are not natively supported and can only be done by recursion using include or using HTTP redirect. The simple design of the language makes it easier to learn and use than most server-side scripting languages, while complicated server-side processing is often done with one of the more feature-rich programming languages. SSI is Turing complete.

Apache, nginx, lighttpd and IIS are the four major web servers that support this language.

SSI has a simple syntax: <!--#directive parameter=value parameter=value --> Directives are placed in HTML comments so that if SSI is not enabled, users will not see the SSI directives on the page, unless they look at its source. Note that the syntax does not allow spaces between the leading "<" and the directive.

236 questions
28
votes
12 answers

Equivalent of include() in HTML

I was wondering wether there is a way to include some html content inside another html using only html? A replacement to PHP's Is this possible? EDIT: This has brought up some confusion, what I needed was "almost an…
Trufa
  • 39,971
  • 43
  • 126
  • 190
16
votes
5 answers

Using too many PHP includes a bad idea?

My question is whether or not using multiple PHP includes() is a bad idea. The only reason I'm asking is because I always hear having too many stylesheets or scripts on a site creates more HTTP requests and slows page loading. I was wondering the…
NessDan
  • 1,137
  • 1
  • 16
  • 34
14
votes
4 answers

What is the scope of require_once in PHP?

Simple question: Is the scope of require_once global? For example: When foo is called, does it re-parse…
TMG
  • 500
  • 2
  • 6
  • 13
13
votes
5 answers

SSI or PHP Include()?

basically i am launching a site soon and i predict ALOT of traffic. For scenarios sake, lets say i will have 1m uniques a day. The data will be static but i need to have includes aswell I will only include a html page inside another html page,…
Ozzy
  • 10,285
  • 26
  • 94
  • 138
13
votes
5 answers

Efficiency for including files of functions (in PHP)

If I had a large number of functions would it be better to keep them all in one large file or would it be better to separate them into several files of related functions. By better I mean more efficient for both maintainability and for the server…
Josh Curren
  • 10,171
  • 17
  • 62
  • 73
12
votes
3 answers

Running PHP without extension without using mod_rewrite?

Using Apache 2.2 and PHP 5, what's the best way to run PHP without the .php extension? For example, I have a script called app.php and I like to invoke it as: http://example.com/app Please notice that I still want to keep the .php extension to the…
ZZ Coder
  • 74,484
  • 29
  • 137
  • 169
12
votes
7 answers

Server side includes alternative

I have a static site hosted on GitHub Pages which is starting to grow in size. Normally I would use server side includes () to bring in header, footer and any navigation files. However php doesn't run on GitHub…
user3406225
  • 121
  • 1
  • 1
  • 3
9
votes
3 answers

Varnish and ESI, how is the performance?

Im wondering how the performance of th ESI module is nowadays? I've read some posts on the web that ESI performance on varnish were actually slower than the real thing. Say i had a page with over 3500 esi includes, how would this perform? is esi…
9
votes
2 answers

OSX 10.10 Yosemite apache upgrade to 2.4, server side includes no longer works

I recently upgraded my Mac to OSX 10.10 Yosemite, which reset a bunch of settings I'd made for Apache, including my virtual hosts set up. I've restored all of that, but I'm still unable to get Server-side Includes working, where they worked fine…
John Egan
  • 225
  • 1
  • 11
8
votes
1 answer

webpack not loading @font-face

in my React app i'm implementing server side rendering so i don't want to add node_modules in my server side because of performance issue.But i want css from from node_modules which are used as UI Kit libs.so i used webpack nodeExternal in my…
zulqarnain
  • 1,536
  • 4
  • 26
  • 44
8
votes
2 answers

JSP equivalent to the PHP include() function?

How should I include an HTML file into another HTML file, using JSP?
Dirk Diggler
  • 863
  • 1
  • 10
  • 22
8
votes
3 answers

Apache regex backreferences UNREACHABLE in httpd 2.4?

I Love the new apache httpd 2.4 with lots of new cool stuff ! ap_expr is one of these new very promising features, ..BUT the following SSI snippet don't work as expected: {{if expr="v('HTTP_SESSION') =~ /-user=([^&]+)/"}} {{set var="user"…
kjetildm
  • 274
  • 3
  • 11
7
votes
1 answer

RegisterClientScriptInclude: What does "type" parameter do?

I'm currently looking into the RegisterClientScriptInclude method so I can be sure that I don't do something like include JQuery twice on one page. The Microsoft documentation states: This overload of the RegisterClientScriptInclude method takes…
Ocelot20
  • 10,510
  • 11
  • 55
  • 96
7
votes
3 answers

Why isn't #include working on .asp page in IIS7.5?

I saw a similar question to this, but mine is slightly different: I'm get intermittent results with #include files working on an IIS 7.5 server (R2008 V2). My includes are only working if they are in the same folder as the current .asp page, or in a…
Mitchell Schaff
  • 103
  • 2
  • 2
  • 10
6
votes
6 answers

How do I limit PHP apps to their own directories and their own php.ini?

I am running multiple PHP apps on my Mac, running OS X 10.5.6, Apache 2, PHP 5. I have subdomains setup for each project, a host file entries for each subdomain, and Virtual Directory blocks in the Apache config. So project1.localhost goes to…
John B
  • 20,062
  • 35
  • 120
  • 170
1
2 3
15 16