Forum Moderators: phranque

Message Too Old, No Replies

Server Side Includes

Precisely, how is this implemented?

         

kaled

1:17 am on Jan 28, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



In theory, an .shtml page is scanned every time it is retrieved and each ssi-comment is replaced. However, is that what actually happens. It seems crazy to repeatedly scan the same page over and over again obtaining precisely the same result each time, so do Apache, etc. perform some sort of optimisation to avoid this unnecessary workload?

Kaled.

jdMorgan

1:46 am on Jan 28, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



No, the page is parsed each time, since the included information might contain variables such as the requested URL, the current date and time, or the output of a cgi script included by an SSI directive.

Any "optimization" would be in the network or client-side caching, if the page is tagged as cacheable. But if it is marked as cacheable, then that's likely to be an error, for the reasons cited above.

In short, it all depends on precisely what the SSI includes are used for, and only relatively-static pages could be cached to prevent the page from being re-requested from the server each time the browser renders it, and therefore prevent the server from having to process the page on each request.

To put this in perspective, though, a modern server can parse a page very quickly though, since the SSI tokens are quite obvious and easy to discern from 'normal' page content. It's likely that the additional server load is much higher for PHP pages than for SSI pages, simply because PHP is a much more powerful scripting environment, supports many more directives, and therefore is probably used much more heavily on the page(s).

Jim

kaled

12:15 pm on Jan 28, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



In that case, I have in mind a simple optimisation.

1) Each .shtml page is treated like a script and compiled into tokens. The tokens contain the original file name (and the position of the ssi instructions on the page), together with the length of the file (for validation) and checksum (if OS makes this available).
2) Each .shtml file would have an associated .ssic file containing the tokens. When the .shtml file is requested, if the date-time stamps of the two don't match (or other checks fail such as file-length and/or checksum) then the .shtml file would be parsed to update the .ssic file.

This should substantially reduce the CPU requirements for SSI.

Any thoughts?

Kaled.