jhx has asked for the wisdom of the Perl Monks concerning the following question:

I was under the impression that the fixup phase only happened once per request, so I thought it was the perfect place to place a tracking script (just does some lookups and sets a cookie). But now it seems that this fixup handler is being called multiple times, sometimes as many as 20 times when you request a directory.

Is this caused by something else that is running? I stripped down my handler to simply log an error at the very start and then decline or OK to stop. Every time I get multiple entries from a single request, with no redirections taking place.

This is such a simple case that I did not provide code, but will if anyone suggests that could be the issue. If the fixup phase is designed to repeat itself, what can you recommend for making my script run only once per request? Thanks so much, I am really taking a liking to Perl!

Replies are listed 'Best First'.
Re: PerlFixupHandler help
by jhx (Initiate) on May 19, 2011 at 21:02 UTC

    I'm on the right track now...this is being caused by apache internal requests or subrequests that are looking for the directory index file. So each test done to look for whatever apache needs runs the PerlFixupHandler again.

    This gives me some new ideas to test, but I welcome insight from those of you familiar with apache. I will post my solution once I have it nailed down.

      return DECLINED unless $r->is_initial_req();

      Guess I just needed to spend some more time studying mod_perl.

Re: PerlFixupHandler help
by Anonymous Monk on May 19, 2011 at 16:06 UTC
    Is this caused by something else that is running?

    No. It is probably caused because a directory usually results in a html page with a bunch of image tags, say, 20 or so of them :)

      Thanks for the reply, but it couldn't be that. This is the initial page response with no content at all, not even HTML headers, just response headers. I will set up a stripped down example page soon so you can see exactly what I mean.