Dr. Mu has asked for the wisdom of the Perl Monks concerning the following question:

I had a rather strange occurence today with a Perl CGI script (running on a remote host under Linux/Apache). This script appends a message to a logfile each time it is run. This message includes the time, some processed data from the query, the remote host and the user agent. I refer to it often just to make sure people are getting the results they expect and, if not, to assist in debugging. In the process of fixing a bug, I also changed the format of the log data. Next, I posted my own query just to test the change, then checked the log file to see how it was processed. Everything looked fine. A couple hours later I checked the log file again to see how things were going with other queries. Everything looked normal except for two entries made more than an hour after my update. They bore the unmistakable format of the old version of my script! I asked my hosting company if they cached scripts in any way, and they said no. But I can't think of another mechanism for this kind of behavior to occur. Has anyone had similar experiences that may shed some light on this anomaly?

Replies are listed 'Best First'.
Re: Script caching?
by johnny_carlos (Scribe) on May 17, 2002 at 05:59 UTC
    Some ideas off the top of my head, prolly not worth too much...

    Is the script in mod_perl? I don't know mod_perl but from what I understand there is caching involved.
    Is there a high load on the machine, or a really high http timeout setting? Perhaps it actually took an hour for those two instances to complete.
    Are you sure there's only one copy? The users don't have bookmarks pointing to the old one or anything?
    Is the script on a cluster of machines maybe?

    john
      Is the script in mod_perl? No.

      Is there a high load on the machine? Can't be sure. It's shared with other sites. My site has light traffic.

      or a really high http timeout setting? Not sure that's relevent, since this was a new session for the recorded client.

      Perhaps it actually took an hour for those two instances to complete. Not likely. They were consecutive, about 55 seconds apart, and from the same client.

      Are you sure there's only one copy? Yes, this particular script has only ever had one name and one location. When I FTP changes, I overwrite the old copy.

      Is the script on a cluster of machines maybe? Not according to my hosting service.

      One other odd observation: After the two anomalous queries, the same client made nine further queries which logged normal responses.

        Even if the script is written as vanilla CGI, if it's being run on apache with mod_perl, there are a couple ways that it could be set up to optimize performance by caching CGI scripts to avoid having to reload and recompile them every time they're referenced.

        By default, apache request-handling processes kill themselves after handling 50 requests, at which point their cached data is lost and the replacement process reloads everything. I suspect that the two anomalous log entries were the result of a process which had previously handled requests for your old script and didn't notice that there was a new version. By now, though, it is long dead and you shouldn't see any artifacts of the old version in the future.

Re: Script caching?
by kappa (Chaplain) on May 17, 2002 at 09:59 UTC
    It's a kind of magic, usual thing in this world :)
    I can imagine that those two queries were made via an older version of your query form which was cached in clients browsers and you mistook data in new format but submitted via an older form for data in old format.
A large helping of crow.
by Dr. Mu (Hermit) on May 17, 2002 at 17:09 UTC
    Dear Monks,

    I owe you all a huge apology for wasting your time with this one. It turns out that the "anomalous" queries were coming in the back door via an HTML form and an an entirely different script that were obsoleted a year ago, yet which functioned so nearly like the prior version of the new one I couldn't tell them apart. Yes, I should have deleted the old script. Yes, I should have directed the old HTML form to the new script. Yes, I should write version information in my log file. I know, I know. And I promise to say 256 "Hail, Larry's" and never do it again.

    Your humble penitent servant,
    Dr. Mu