NameSniper
09-22-2006, 05:19 PM
There are a number of cases where a webmaster should implement includes.
One the most common cases is that the one has often updating info and displaying it on another page with teh help of includes but includes are making the website to load slower since a user should initiate one more connection to apache to get that "separate page/frame"
Is there a script which can make a plain html code from a particular incldue every 1 or xx minutes and add it into another pahe html code ?
ThatScriptGuy
09-22-2006, 05:41 PM
Perhaps look into output buffering? Look up ob_start on php.net
You could generate the page every minute and then save it to a static html page using output buffering...
ThatScriptGuy
09-22-2006, 07:19 PM
Look...
Let's say that you have a dynamic index.php page......and you want to have it generate a static html page every minute..It's very simple to do...
Start the script off with <?
ob_start();
and end it with
$content = ob_get_contents();
$file = @fopen('index.html','w');
if ($file !== false)
{
@fwrite($file,$content);
fclose($file);
}
Then just run a cron job to access this php script every minute and everytime it is run, it will generate index.html...So when your visitors come, they will get the static version, which is updated every minute by your cron job...
Kevin
NameSniper
09-22-2006, 07:51 PM
As i understood it will create html page from my current php page(my index page consist of the page content+includes) ?
ThatScriptGuy
09-23-2006, 11:09 AM
Exactly...that will store whatever HTML is generated by your PHP code into a file called index.html
NameSniper
09-26-2006, 12:30 PM
Kevin thanks a lot,it has worked out )
sasha
09-26-2006, 01:25 PM
There are a number of cases where a webmaster should implement includes.
One the most common cases is that the one has often updating info and displaying it on another page with teh help of includes but includes are making the website to load slower since a user should initiate one more connection to apache to get that "separate page/frame"
This is not true. Handling includes in entirely server issues and client is never aware if it happens and how. Client will make only single request and apache will handle includes on its own.
NameSniper
09-26-2006, 03:36 PM
Sure but it makes website to load slower,i never said that it will cause issues on user side
maxymizer
09-26-2006, 05:39 PM
Sure but it makes website to load slower,i never said that it will cause issues on user side
It makes the website load slower maybe 1% - 3%. Bottleneck is ALLWAYS database. After you cache queries (dump output to a file), you'll notice a large performance gain (which you allready did)..it's got nothing to do with using includes as such, but you're probably performing db queries in those includes. Anyway, caching is way to go and save resources but avoiding using includes for anything because you think that it it has HUGE impact on loading the site is plain wrong.