hacker has asked for the wisdom of the Perl Monks concerning the following question:
I have a small piece of code running under mod_perl and Apache::Registry (using a module is not an option at this point) and I've run into a very odd caching issue.
When I reload the same page over and over and over, printing out what $vars{action} should contain, I get very incorrect results.
My initial page is 'index.pl?action=home'. I'm exposing this variable with:
print p("\$vars{action} passed was: $vars{action}\n") if $vars{action} +;
When I reload that page successively, I get:
$vars{action} passed was: news $vars{action} passed was: home $vars{action} passed was: $vars{action} passed was: dl
..which matches any of the various vars that have been passed in the past to this script. It seems like past "clicks" to this CGI are persistant. I understand that these should be persistant for the life of the server process, but $vars should not be persistant, should it? The relevant code is as follows:
use strict; use warnings; use diagnostics; use Env; # Send errors to browser use CGI::Carp qw( fatalsToBrowser ); use CGI qw(:standard); my $query = CGI->new(); my %vars = $query->Vars(); # CGI.pm print header(), start_html(), and basic HTML goes here print p("\$vars{action} passed was: $vars{action}\n") if $vars{action} +;
Is there something I'm not seeing here? Should $vars be persistant throughout reloads? With more than one server process and more than one user hitting different options from the site, this could get very confusing and very ugly if a user clicks 'Download' and gets the 'News' page from the previous user's clicking.
I tried autoflushing at the top, but that didn't help. All of the possible variables are locals, not global, with the exception of those started in cgi-bin/startup.pl, as required by the Apache::Registry/mod_perl documentation.
Did I miss something?
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: "caching" issue with mod_perl?
by dsheroh (Monsignor) on Jun 10, 2002 at 20:08 UTC | |
Re: "caching" issue with mod_perl?
by perrin (Chancellor) on Jun 10, 2002 at 21:11 UTC | |
by hacker (Priest) on Jun 10, 2002 at 22:01 UTC | |
by perrin (Chancellor) on Jun 11, 2002 at 01:05 UTC |