Friday, May 23, 2008

cached site and css

This morning I fixed some css problems on analytics. I learned about classes in css. With the use of CSS Classes you can have more than one style per HTML element. Then this afternoon I learned about caching a analytics page for 7 days using php script, since the original page took up to 30 second to load. first I created a folder where the cached files will reside. then used these functions to see if there is a cached version of the site within the last 7 days. $File is the location of the folder and the file name. This works great....

$Cached = "folder/Site.xml";
if($Xml = $this->GetCachedXml($Cached))
{
$this->XML = $Xml;
}
else
{
//load new XML
}

private function GetCachedXml($File)
{
if(!file_exists($File))
{
return false;
}
elseif(filemtime($File) < dom =" new">load($File);
return $Dom;
}
}

private function SaveCachedXml($File, $Xml)
{
$Xml->save($File);
}

Please check out one of our clients: http://canadamortgagefinder.net/

No comments: