http://www.perlmonks.org?node_id=483958

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

I'm trying to prevent IE from caching my CGI program. Right now I'm using the standard methods in CGI. I've tried the following:
print header(-expires=>'-1d');
and
<META http-equiv="Expires" content=" Thu, 25 Jul 2002 08:12:13 GMT">
and
<META http-equiv="Pragma" content="no-cache">
Can anyone help?

Replies are listed 'Best First'.
Re: IE cgi caching
by !1 (Hermit) on Aug 15, 2005 at 19:32 UTC
    This will probably help.
Re: IE cgi caching
by gryphon (Abbot) on Aug 16, 2005 at 02:10 UTC

    Greetings Anonymous Monk,

    What !1 referenced looks very cool and is a much better option than my idea, but for completeness: What has worked for me in the past is to specify some throw-away query parameter that is always changing. For example:

    my $url = 'yourscript.cgi?data=realdata&ignore=' . time . rand # Then feed $url to links in refering pages

    Every time you click a link from a refering page (which itself has to be a script because it generates the random URL), you get a new unique URL for which IE has no cache. Just ignore the ignore parameter. It's hokey; it's stupid; it's a hack, but it has the value of working.

    gryphon
    Whitepages.com Development Manager (DSMS)
    code('Perl') || die;