The scope of this post is software development. If you are not involved with web application development, this post is probably of little value to you.
While designing the Grogg blog engine
, which powers this site, my ambition was to minimize the response time for page load.
One way of doing this is to generate pure HTML file from data base content which the web server simply send out at requests. This would be very efficient, but not very flexible, as no server-side scripts could alter the contents. Only static content would be possible by this scheme.
Another possible solutions is to not generate HTML files but PHP and PHTML files. This is the solution I chose for Grogg
. Time consuming data base queries and such can be used while generating the PHP or PHTML files, without penalizing performance at request time. Dynamic server-side scripting is still possible - as the PHP and PHTML is still interpreted at request time.
As you can see, the response time for the MKJE
site is not bad, event though all content is dynamicly generated.
How to generate PHP files from templates.
To generate a, lets say, HTML files by the use of PHTML files is trivial. But how to generate a PHTML or even a PHP file based on a template in PHP?
SCT - Source Code Templates
The SCT engine can generate PHP or PHTML files by taking a SCT template file and optional arguments as in-data. In a way very similar to the way PHTML code is used to generate HTML content. The SCT engine looks for the special SCT tags (<## ... ##>
, <##= ... >
), and executes the PHP code inside to generate dynamic content. Text and PHP code outside the SCT tags will be passed through the SCT engine unchanged.