Reputation: 3146
I'm asking in regards to otherwise-static webpages which include files like headers, footers, etc. Obviously building a dynamic site with SSI would be better done with PHP.
Is there ever any reason to do
<!--#include virtual="../quote.txt" -->
instead of
<?php include("../quote.txt"); ?>
(or the equivalent in another language)?
I'm asking because I've been given the task of updating a website which is currently using SSI for including the same header on different pages.
Upvotes: 2
Views: 230
Reputation: 798
There are some circumstances where SSI can really be helpfull e.g. when an application caches rendered pages and you need to clear the cache but don't want to clear all pages cause of a simple menu change. Then you could just replace the menu or several menus by an ssi include and just clear the menu files on a change an leave the cached pages intact.
Upvotes: 0
Reputation: 197787
include
is not the PHP equivalent of #include virtual
, that would be: virtual
Docs.
So it's not only that you can mimic with PHP what SSI directives are doing.
You can even run PHP through SSI if you have a CGI handler configured. And you can run SSIs if mod_php
is enabled.
So this might be helpful to know if you redesign the current site and probably think about changing away from SSIs.
See Apache Module mod_include for more details.
Upvotes: 1
Reputation: 180023
If you're not using any other PHP in the page, using an SSI means your Apache processes don't need to load up the PHP interpreter to generate and serve the HTML.
Upvotes: 2