This is really more of a HTTP- than Perl-related post; the following snippet emits all of the currently specified HTTP headers that may affect caching, with values set to coerce clients into not caching the document in question. Itís useful for debugging as well as generated pages that actually are very dynamic, but shouldnít be used blindly for everything Ė caching is there for a reason.
(Iím posting this here mainly so as to have a node to refer people to as needed.)
use CGI qw(:standard);
use POSIX qw(strftime);
# date in the past
-expires => 'Sat, 26 Jul 1997 05:00:00 GMT',
# always modified
-Last_Modified => strftime('%a, %d %b %Y %H:%M:%S GMT', gmtime),
-Pragma => 'no-cache',
# HTTP/1.1 + IE-specific (pre|post)-check
-Cache_Control => join(', ', qw(
I spent quite a little while trying to determine why I was unable to get CGI::Application::Plugin::Authentication to work correctly with my CGI app; I'd fill in the login form, click the button, but no joy. Click again. Then again. Then, on the fourth try, the login would go through. But sometimes it took 5 clicks. Sometimes only 3. Drove me batty, until I realized that the web server was cacheing the result of cgi scripts... set at 10 seconds. Firefox wouldn't submit the login form's data to the script until 10 seconds had passed since the time the login form appeared in the browser.
I control the Apache config file on my server, and fixing the problem on the server side was easier for me. It was a matter of removing this line: