[tpm] Using mod_perl

Indy Singh indy at indigostar.com
Fri Apr 18 08:14:16 PDT 2008

Hi everybody,

While we are on the topic here are some questions I have about mod_perl.

I am porting a CGI script to mod_perl, mostly the porting is transparent
however I have a couple of questions.

1) Multiple apache/mod_perl instances
After making a change to the script and pressing refresh in the browser,
sometime the script works sometimes it gives an error.  I know from past
experience that the browser requests will be processed by one of several
apache instances.  How do you force all mod_perl instances to reset
everything and start with a fresh instance?  Is it enough just to update
the script source?  If I update the source code, will all the apache
instances reload the script?

2) Browser caching
When I fetch a result page by clicking on a link, the browser could
decide to redisplay the same (out-of-date) output as the last time the
page was fetched.  How do you get the browser to fetch a new result each
time?  Does it happen automaticy if the script output does not contain a
date header?

3) Caching of database handles.
I am assuming that in my script I can cache a mysql database handle and
thus avoid a new database connection, however what happens if the
database connection has been abandoned by the database server? I don't
know if such a thing is possible, but I trying to program defensively.
I am thinking that at some point for whatever reason the database server
droped the connection, but the mod_perl script does not know about it.
The script tries to uses the old database handle and will fail.  Would a
good way to handle that be to display an error message to the browser
and close the database connection (just in case it is still open) and
then set the database handle to undef?

Indy Singh
IndigoSTAR Software -- www.indigostar.com

More information about the toronto-pm mailing list