Page 1 of 1

home page now static

Posted: Tue Sep 07, 2004 11:43 pm
by Red Squirrel
The home page updates only every 15 minutes, and if no one goes on within 15 minutes it won't update. So the way it works is that every time someone goes on it checks if it got updated in the last 15 minutes, if not then it updates,if yes then it just loads the static page.

So it's not 100% static, but very close. Only the logger, a bit of code and then the static page load, compared to all the sql queries there is to process the home page.

So these queries will only happen every 15 minutes or so.

I will eventually do this with the articles as well but it will be more complicated to program.

Archived topic from Iceteks, old topic ID:2612, old post ID:21539

home page now static

Posted: Wed Sep 08, 2004 4:02 pm
by Anonymous
I don't know if you are familiar with Craigslist, but this is a similar idea. A very good idea. B)

Archived topic from Iceteks, old topic ID:2612, old post ID:21542

home page now static

Posted: Wed Sep 08, 2004 4:35 pm
by Red Squirrel
What I used was output buffering.

Actually this is the code:

Code: Select all

<?php require("master_config.php"); ?>
<?php include($iceteks_vars[serverpath]."scada/mainlogger.php");


//check last update
$handle = fopen($iceteks_vars[serverpath]."static/timers/index.t","r");
$lastupdate = fgets($handle);
fclose($handle);


if($lastupdate<(time()-900)) //update if too old   - 900 = 15 minutes
{
//write new time
$handle = fopen($iceteks_vars[serverpath]."static/timers/index.t","w");
$lastupdate = fputs($handle,time()."
");
fclose($handle);


//write new page
$handle = fopen($iceteks_vars[serverpath]."static/pages/index.htm","w");

ob_start(); //start buffer and include module
include($iceteks_vars[serverpath]."static/modules/index.php");
$lastupdate = fputs($handle,ob_get_contents());
ob_end_clean();//end buffer

fclose($handle);

echo("<!--Page Regenerated-->
");
}


include($iceteks_vars[serverpath]."static/pages/index.htm");
?>

[code]

The index.php in the modules is the actual page that I would edit to change something on the home page, it has php and html in it.

Oh and welcome aboard.  :wave:  

[color=#888888][size=85]Archived topic from Iceteks,  old topic ID:2612, old post ID:21543[/size][/color]