Caching
Well there is page caching and more granular caching including function caching (such as database queries).
Page Caching
Pages are cached server-side… eventually as content and also as a whole page (including “skin” and anything from the render engine).
Server-side page caching duration (cache lifetime) is defined by the $HS_config['cachingLifetime'] setting in config_site.php.
Defining non-cachable blocks
Idea 1 (orig.)
To define something as non-cacheable simply print (such as by closing any open <?php ?> tags) the following:
[?php[
//Your code goes here. For example:
print('Copyright '.date(Y).' Alan Hogan');
//Note that you do NOT need <?php ?> tags; they are inserted
//for you. Think of [php[ /* ... */ ]php] as the same thing, but
//superdynamic and uncacheable.
]?]
Idea 2 (somewhat standard)
Maybe we will support
<nocache> /* code */ </nocache>
syntax like some other CMSes do.
Idea 3 (pretty friggin sweet)
Actually use PHP syntax, but surround non-cacheable bits with the /*nocache*/ ... /*endnocache*/ markers.
Code blocks that should be executed for both “compiling” (cacheable) and dynamic (non-cacheable) operations should be surrounded with /alwaysrun/ … /endalwaysrun/
The advantages of this:
Normal code editors & highlighters will work as expected
Don’t have to open and close
<?php ?>tags all the time. NOTE: Code between the/*nocache*/and/*endnocache*/markers should contain only complete PHP commands, that is:print "<p>Hello</p>"; /*nocache*/ print "<p>Current date and time is ".date("Y-m-d H:i:s')."</p>"; /*endnocache*/ print "<p>Good bye<p/>";is good while
print "<p>Hello</p>" /*nocache*/ ."<p>Current date and time is ".date("Y-m-d H:i:s')."</p>" /*endnocache*/ ."<p>Good bye<p/>";is bad, because in the latter case, after “compiling” the PHP interpreter will not have a whole statement to execute, and nothing will ever get printed.
As an aside, there is no reason not to embed HTML in nocache blocks, e.g. like:
/*nocache*/ ?> if($foo) { <p>Currently we are foo!</p> <?php } /*endnocache*/However one issue to keep in mind is that
/*nocache*/ ... /*endnocache*/, if not surrounded by backticks (`) to let it know it’s code, will actually be considered italic by Markdown, and converted to /nocache/ … /endnocache/.
Module Caching
Names of things being cached should not have any underscores (_). Those are reserved to separate logical hierarchies; that is, within the “modules” group of caches, if a module is the “timebomb” module (I made that up), and it caches a “clock” then its name is “clock”, not “my_clock” or anything… so the effective name that cache_light sees is “timebomb_clock”. That should make sense because clock is owned by timebomb; it is beneath it in a hierarchy.
