Results 1 to 11 of 11
  1. #1
    Join Date
    Mar 2004
    Posts
    1,005

    Script to get rid of includes

    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 ?
    Best Regards,
    Namesniper

  2. #2
    Join Date
    Feb 2003
    Location
    AR
    Posts
    2,381
    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...

  3. #3
    Join Date
    Mar 2004
    Posts
    1,005
    More info pelase?
    Best Regards,
    Namesniper

  4. #4
    Join Date
    Feb 2003
    Location
    AR
    Posts
    2,381
    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
    PHP Code:
    <?
    ob_start
    ();
    and end it with
    PHP Code:
    $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

  5. #5
    Join Date
    Mar 2004
    Posts
    1,005
    As i understood it will create html page from my current php page(my index page consist of the page content+includes) ?
    Best Regards,
    Namesniper

  6. #6
    Join Date
    Feb 2003
    Location
    AR
    Posts
    2,381
    Exactly...that will store whatever HTML is generated by your PHP code into a file called index.html

  7. #7
    Join Date
    Mar 2004
    Posts
    1,005
    Kevin thanks a lot,it has worked out )
    Best Regards,
    Namesniper

  8. #8
    Join Date
    Feb 2003
    Location
    AR
    Posts
    2,381
    Good to hear

  9. #9
    Join Date
    Oct 2002
    Location
    Canada
    Posts
    3,100
    Quote Originally Posted by NameSniper
    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.

  10. #10
    Join Date
    Mar 2004
    Posts
    1,005
    Sure but it makes website to load slower,i never said that it will cause issues on user side
    Best Regards,
    Namesniper

  11. #11
    Quote Originally Posted by NameSniper
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •