caching the homepage. Would this work?

Hi - Im a beginner with php. I just found this article about caching php pages as html for faster access - and I thought that if it can be adapted to work with Dolphin then its probably a very valuable idea as our main Hompages tend to load pretty slowly, no?

http://papermashup.com/caching-dynamic-php-pages-easily/

Heres the relevant code in case you cant be bothered to click the link


$cacheFile = 'cache/index-cached.html';
$cacheTime = 4 * 60;
// Serve the cached file if it is older than $cacheTime
if (file_exists($cacheFile) &amp;&amp; time() - $cacheTime < filemtime($cacheFile)) {
include($cacheFile);
exit;
}
// Start the output buffer
ob_start();

/* Heres where you put your page content */

// Cache the contents to a file
$cached = fopen($cacheFile, 'w');
fwrite($cached, ob_get_contents());
fclose($cached);
ob_end_flush(); // Send the output to the browser

So if it would work where in the site would one put this code?

DV

Quote · 19 Mar 2009

If your trying to cache the home page then try the end of index.php after the last function but before the ?>

 

 

Quote · 19 Mar 2009

Thanks I guess I will try it and see if it speeds up loading significantly

Quote · 20 Mar 2009

.

More than likely if you're having speed issues it has something to do with excessive content, images that are grossly oversized, and stuff like that. Consider this, as far back as 2000, now 9 years ago, there was plenty of multimedia content being used on the internet without too much of a problem if you knew what you were doing back then to make things quicker.

However, today, 9 years later, the servers have much much faster processors - memory has been hugely expanded - hard disks have in some cases up to 32 MB cache buffers - hard disks are also considerable faster now - and then of course, instead of using 56K modems (or slower) just about everyone has dsl these days, wireless or otherwise.

.

Site content itself, aside perhaps from adding videoclips and mp3 archives, really hasn't changed at all since 2000 and that's why I believe that a slow site today is probably making use of "stuff" that causes everything to be slower needlessly ... such as massive images and such. Although, if you have a "virtual server" that's actually a part of one big server with numerous clients, that could potentially cause problems too ... if that server gets pushed too hard by all of those accounts. Just my 2 cents worth, would have been nice if you'd included a link to your community. Here's a link to ours:

.

.

Greetings from Germany

Quote · 20 Mar 2009

well yes the problem is too many files ( I dont think they are particularly big - but my understanding is that the database queries for...

random, latest, top - photos, videos, music, blog posts, forum posts, etc etc -

must slow it down considerably and agravate the problem even more -  no ?

And the purpose of this code I posted  is just to cache the whole page, say every 5 min, so that its just sending the html without needing to go through the database for each visitor to the main page...

Im a beginner so Im running this by you to see if I am right or not.

Please comment.

Also I begin to suspect from some of the code in the index.php file that Dolphin has some sort of ability to do this caching built into it - anyone know about this ?

By the way my site is oneearth.ws - but a while ago when everyone was being hacked people stopped posting their urls here for fear that it would attract attention to them :-(

I figure, what the hell... I want to be noticed. And I might as well find out asap if their are people with nothing better to do than make me reinstall a backup for kicks.

Dan V

Quote · 26 Mar 2009

Dolphin can be pretty slow if you homepage is filled with garbage. For firefox, install Firebug and YSlow, extensions that are freely available and will help you identify what causes the page to load for ages.

Quote · 27 Apr 2009

I notice someone has now released a mod on Expertzzz that caches pages.

Well I guess there is some point in posting questions to this forum as it does seem to inspire programmers to provide needed features ;-)

Quote · 27 Apr 2009
 
 
Below is the legacy version of the Boonex site, maintained for Dolphin.Pro 7.x support.
The new Dolphin solution is powered by UNA Community Management System.