Gossamer Forum
Home : General : Perl Programming :

browser no cache

Quote Reply
browser no cache
How can I tell the browser not to cache my file.cgi.

Quote Reply
Re: browser no cache In reply to
As an example, taken from Links 2.01 and 2.0, you can do the following:

1) Replace all occurrences of print "Content-type: text/html\n\n"; with the following codes:

Code:

&html_print_headers;


2) Then add the following subroutine:

Code:

sub html_print_headers {
# --------------------------------------------------------
# Print out the headers if they haven't already been printed.
#
if (!$html_headers_printed) {
print "Pragma: no-cache\n" if ($db_nocache);
print "Content-type: text/html\n\n";
$html_headers_printed = 1;
}
}


3) Then add the following variable:

Code:

# Use Pragma: no-cache to stop browsers from caching output? (0 = cache, 1 = nocache)
$db_nocache = 1;


Hope this helps....

Regards,

Eliot Lee

Quote Reply
Re: browser no cache In reply to
Hi

Thank you for your response ...unfortunately it doesn't work with MSIE.

I'm creating a cgi for images rotation. I'm calling the "banners" without SSI... Just a img src=file.cgi

MSIE seems working only when I disable my "temporary internet files".



Quote Reply
Re: browser no cache In reply to
try:

print "Cache-Control: no-cache\n";
print "Cache-Control: no-store\n";
print "Pragma: no-cache\n";
print "Content-Type: text/html\n\n";

that should pretty well cover ya

--Gordon


s/(\d{2})/chr($1)/ge + print if $_ = '8284703280698276687967';
Quote Reply
Re: browser no cache In reply to
I put them in the script but MSIE is still giving the same problem. Banners are stored in the cache.... when I use the 'back' and 'next' arrows in the browser I see the last banner loaded

Any ideas?

Thank you.

Quote Reply
Re: browser no cache In reply to
You can also add:

Expires: Some Date in the past

Using CGI.pm, just do:

print $in->header ( -expires => -1d );

Cheers,

Alex

--
Gossamer Threads Inc.
Quote Reply
Re: browser no cache In reply to
Sorry ... I don't want to use cgi.pm. I can't believe that there are no methods to solve this in basic perl.

Quote Reply
Re: browser no cache In reply to
We use the following in our cgi script:

print "Cache-Control: no-cache\n";
print "Pragma: no-cache\n";
print "Expires: 0\n";
print "Set-Cookie: login=0;\n";
print "Content-Type: text/html\n\n";

Granted we are also removing a cookie at the same time, but this ha shown us that in both of the big browsers, it does work for us and the page is not cached.


"I've got if's pretty good, but that's about it"