> Is there a way to cache the parsed representation externally in a
> variable? If not, I quess my best option is to write out the strings to
> a tmpfile and use it with ns_adp_parse -file.
My prefered way of doing this is doing the ns_adp_parse and then writing
the results to a file. The name of the file would be something like the
"news/12345.html", where "12345" is the ID of the news article requested.

On any request, you check if the required file exist and if it does, use
ns_returnfile to send it.

To clear the cache, simply delete the file.

Be sure to create a temp file (use the conn id as name) for writing and
then "file rename" it to the real name. This will make sure you never have
the problem where one thread is writing the file and another returns it,
but only the part written already.

To make this _really_ high performance, have requests go to something like
/news/12345.html. If the file does not exist in the pageroot, your custom
404 handler ADP can figure which one was requested, generate it, cache it
and return it.

In a variation, you can use this this to write just part of a page and
include it in a greater page with other cached or dynamic parts. You are
best to use "set fp [open somefile]; set data [read $fp]; close $fp"
instead of ns_adp_parse to include the cached files as that won't invoke
the parser and cost you some needless cpu time.

Hope that helps,
Bas.


--
AOLserver - http://www.aolserver.com/

To Remove yourself from this list, simply send an email to <[EMAIL PROTECTED]> 
with the
body of "SIGNOFF AOLSERVER" in the email message. You can leave the Subject: 
field of your email blank.

Reply via email to