Thanks to all, this is indeed most enlightening for me as I've only been
using PHP for about 6 months. The output buffering and saving of generated
HTML pages (using a hashed name) could be very beneficial, saving hundreds
of quite lengthy MySQL queries each day.

Brad: When you say "a hash of the query string" do you mean passing the
variable part of the URL thru mhash to obtain a hash/key/digest or whatever
you wish to call it? If so, do you recommend any particular hash, ie MD5,
GOST or TIGER? Not knowing much about these things, I imagine passing the
same text thru a given hash algorithm multiple times will always return the
same result.

So:

Requested URL
http://server/app/page1.php?cust=12345&t=3

Variable part hashed
page1.php?cust=12345&t=3 > hash > mdg4789gnvh095n

If the following URL exists use it, otherwise do processing, get buffer and
write to this file.
http://server/app/static/mdg4789gnvh095n.html

If PDF of page requested:
Send the current URL (http://server/app/static/mdg4789gnvh095n.html) through
pdf-o-matic or similar.

Is that about right?

Many thanks
Great list !!

Graham

-----Original Message-----
From: Brad Pauly [mailto:[EMAIL PROTECTED]
Sent: 23 September 2004 17:17
To: [EMAIL PROTECTED]
Subject: Re: [PHP] Re: PDF from PHP generated HTML, possible?


On Thu, 23 Sep 2004 16:25:27 +0100, Graham Cossey
<[EMAIL PROTECTED]> wrote:
> That's fine for static pages, my question was regarding dynamic pages that
I
> did not wish to pass through the database querying again.
>
> I understand that if my dynamic page is
> http://server/app/page1.php?cust=12345&t=3 I can supply that URL which
will
> result in HTML that can be processed by (for example) pdf-o-matic.
However,
> as I've already run all the queries necessary I would like to not have to
> run them all again when requesting the PDF.

At the beginning of your page1.php script (and any others that you
want to cache as html and pdf) you could check to see if you have
created cached version of the page, if so, redirect to that page. If
not, use output buffering and save the generated content to a file.
Run that file through the pdf-o-matic to create the pdf version. You
could name the file by creating a hash of the query string and any
other variable that affects the dynamic content of that page (for
example, session variables). So the original request might look like
your example.

http://server/app/page1.php?cust=12345&t=3

Which, if it has a cached html version would redirect to a different
URL before any of your queries are executed.

http://server/html/<hash-of-your-variables>.html

Or, for the pdf version.

http://server/pdf/<hash-of-your-variables>.pdf

- Brad

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to