Hi There, so..

I have built a content management system that works very nicely to produce PHP pages.

What i would like it to do next is to run that php once as if a user was looking at it and save the results as an HTML file (i.e. just the HTML not any code). then that would be what the users see.
That way it would take the load off the server and also make things happier for the search engines.

I'm sure i saw a tutorial on this somewhere when i was learning php but it was a while ago and that was the least of my worries back then ;-)

Thanks,
Hugh

    "file->save as" menu on any browser.....

    or view source and save the txt file that opens...

      sorry, I should have said..

      I would like to have php generate it all for me. Below is a kind of flow of what i want:

      example.php PHP page
      -> example.php includes and any code executed
      -> PHP saves executed results as example.html

      hope that clears things up
      ta,
      Hugh

        rather than using ECHO and PRINT use fopen/fwrite/fclose....

        dont see why that wouldn't work...

          but can i tell php to execute the code as a user would on example.php without visiting it or would i set it up as a cron job to execute each page every minute or so.

            Rough sketch of one approach:

            1. ob_start()

            2. include (full URL of page to cache)

            3. ob_get_contents()

            4. ob_end_clean()

            5. save the contents as a file.

            file-exists() will also come in handy to see if the cached version is around or not.

              Thanks Weedpacket,

              Looks like the way to go but i'm not very familiar with those functions, time to get the brain working.

              Cheers,
              Hugh

                Some template engines (I am thinking of the one in phpBB, SMARTY probably can aswell) can cache a page after it has been called once.

                  Write a Reply...