Welcome to Geeklog, Anonymous Saturday, December 21 2024 @ 12:10 pm EST

Geeklog Forums

geeklog cache-speedup


Status: offline

hangshi

Forum User
Newbie
Registered: 08/20/03
Posts: 8
hi,geeks:
I am a newbie, and just finished setup geeklog system on a virtual-hosting service. but I found the speed of loading was slow,especially the
index.php. meanwhile, I search geeklog site for solution, found a lot help there, but, just like you know, phpaccelerator, mmturcke ......need server site setup. so, it is not convenient, I have found a snipt code, and Have test it seem work, but I can't make sure it is really good to fit geeklog? and can it be used to onther php files within geeklog system?

thank you a lot!!!

my code bellow:
cache.php //include file
<?php
function GetCacheFileName($aFileName)
{
return $aFileName . ".cache";
}
function DumpCacheFile($aFileName, $aExpire=3600)
{
$aCacheFile=GetCacheFileName($aFileName);
if ( is_file($aCacheFile)==True)
{
$aModtime=filetime($aCacheFile);
$aCurTime=time();
if (($aCurTime-$aModTime) > $aExpire)
{
return False;
}
else
{
readfile($aCacheFile);
return True;
}
}
}
function SaveCacheFile($aFileName, $aContents)
{
$aCacheFile=GetCacheFileName($aFileName);
$aFile=fopen($aCacheFile, "w&quotWink;
fwrite($aFile, $aContents);
fclose($aFile);
}
?>

then put some code in index.php top:

error_reporting(E_ALL & ~E_NOTICE);
include("./cache.php&quotWink;
if ($aResult=DumpCacheFile("index.cache",60*60))
{
//THERE WAS A VALID CACHE FILE,EXIT SCRIPT
exit;
}
ob_start();

and put bellow code in index.php bottom:

SaveCacheFile("cache", ob_get_contents());



hangshi
2003/8/22
 Quote

Status: offline

hangshi

Forum User
Newbie
Registered: 08/20/03
Posts: 8
I have wait for reply for a long time. but on reply Confused . I really don\'t know what\'s wrong with my question. anyway, I do need help. any idea will be welcome! thanks! hangshi
 Quote

Mark

Anonymous
You may not have gotten a response because noone understood your question or do not know the answer. It looks like you want to use cache to improve the speed but what Geeklog files are you trying to cache? There are a lot of database calls could this be the source of your speed problem? I run a Geeklog site on a server which does not have any accelerator and the speed is okay.
 Quote

Status: offline

Dirk

Site Admin
Admin
Registered: 01/12/02
Posts: 13073
Location:Stuttgart, Germany
hangshi: I\'m with Mark on this one - I don\'t understand what your problem is and what kind of answer you expect. I\'ve collected a few tips in an FAQ article now, maybe it helps: How can I speed up my Geeklog site?. bye, Dirk
 Quote

Status: offline

hangshi

Forum User
Newbie
Registered: 08/20/03
Posts: 8
thanks dirk and anyone. I am sorry for reply late. What I mean is the \"cache.php\" can be used in \"index.php\" within geeklog system. and is it correct that I have had already used in \"index.php\" upside? because, I found that every time I visit my site it always upgrade the \"afilename.cache, but did not visit the \"afilename.cache\" even the the time was not expired. thank you! looking for reply!!
 Quote

All times are EST. The time is now 12:10 pm.

  • Normal Topic
  • Sticky Topic
  • Locked Topic
  • New Post
  • Sticky Topic W/ New Post
  • Locked Topic W/ New Post
  •  View Anonymous Posts
  •  Able to post
  •  Filtered HTML Allowed
  •  Censored Content