[Site Home] [Forum Home] [Articles] [File DB] [News Archives]

IceTeks Changes -> home page now static


(View original topic)


Red Squirrel - Sep-08-2004 server time
What I used was output buffering.

Actually this is the code:

CODE

<?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()."\n");
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-->\n");
}


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



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.gif

IceNine - Sep-08-2004 server time
I don't know if you are familiar with Craigslist, but this is a similar idea. A very good idea. cool.gif

Red Squirrel - Sep-07-2004 server time
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.

(Showing 50 last posts, newest on top)