home page now static

Announcements about the forum or services itself
Locked
User avatar
Red Squirrel
Posts: 29209
Joined: Wed Dec 18, 2002 12:14 am
Location: Northern Ontario
Contact:

home page now static

Post 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
Honk if you love Jesus, text if you want to meet Him!
Anonymous

home page now static

Post 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
User avatar
Red Squirrel
Posts: 29209
Joined: Wed Dec 18, 2002 12:14 am
Location: Northern Ontario
Contact:

home page now static

Post 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]
Honk if you love Jesus, text if you want to meet Him!
Locked