PHPBuilder - Cached Dynamic Modules Page 6



RSS Twitter
Articles Site Operation

Cached Dynamic Modules - Page 6

by: JP
|
July 30, 2000

An interesting side-effect is that in the handle_xxx function you can use the parse_it function again to parse external retrieved data. Say that you have a <my-include file=..>, that file can also contain new <my-..> tags if you implement res/include/include.php as follows:

<?php

 
function handle_include ($arglist) {
    if ((
$arglist["file"]) && ($f fopen ($arglist["file"], "r"))) {
        
$buf "";
        while (
$str fgets ($f4096)) 
            
$buf .= $str;
        
fclose ($f);

        return 
parse_it ($buf);
    }
    return 
"<!-- include: error opening " $arglist["file"] . " //-->";
}

?>
Using caching here will probably provide useful if including from external sites:
<my-include file="http://remote.server.com/foo.my" cache=3600>
This way, the file is only fetched from the remote server once an hour, for all the other requests the cached entry is used, which is much faster.
-JP

« Previous Page
1
|
2
|
3
|
4
|
5
|
6

Comment and Contribute

Your comment has been submitted and is pending approval.

Author:
JP

Comment:



Comment:

(Maximum characters: 1200). You have characters left.