Reply to Re: [PHP] Writing static file from dynamic PHP page

Your name:

Reply:


Posted by John Hicks on 01/19/05 18:09

Chris Bruce wrote:

> Hi,
>
> I am looking for a way to write to a file what the browser would see
> (raw html) when viewing a dynamic PHP page. I have numerous include
> files, MySQL db queries, loops etc. and I want to generate the static
> result of that file and save it as an html page. I have toyed a little
> with output buffering to no avail.
>
> Is there an easy way to do this?
>
> Thanks,
>
> Chris
>
Here's a great article on the subject from the Zend website:

http://www.zend.com/zend/art/scriptcaching.php

It's a little more complex than you would hope but is well thought out.
--Separate directories is set up to hold the php source and the cached html.
--The cached html directory is initially empty.
--An Apache ErrorDocument directive is used to intercept the "404
document not found" error when someone is requesting a page and to
redirect it to a single caching script.
--This caching script uses fopen() to open and then read the php script
and to write the output to the cached html directory.

Hats off to Zend for publishing this. It competes with their Zend Cache
product. From the article:

"If your site contains a few small scripts, you may not need to bother
with caching at all. On the other hand, if you rely on complex scripts
and fresh data, you should use a much more sophisticated solution, such
as the Zend Cache <http://www.zend.com/store/products/zend-cache.php>.
But if you are somewhere in between, I hope this article will be of help
to you. If you have any comments, please feel free to email me."

(Sorry to take so long to post this. I had remembered reading the
article but couldn't find it. Finally thought to do a Google for "404
php cache".)

Hope this helps,

-John

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация