How can I tell the browser not to cache my file.cgi.
Sep 24, 2000, 10:40 AM
Veteran (17240 posts)
Sep 24, 2000, 10:40 AM
Post #2 of 8
Views: 4677
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:
&html_print_headers;
2) Then add the following subroutine:
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:
# Use Pragma: no-cache to stop browsers from caching output? (0 = cache, 1 = nocache)
$db_nocache = 1;
Hope this helps....
Regards,
Eliot Lee
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
Oct 6, 2000, 12:48 PM
Administrator (9387 posts)
Oct 6, 2000, 12:48 PM
Post #6 of 8
Views: 4644
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.
Expires: Some Date in the past
Using CGI.pm, just do:
print $in->header ( -expires => -1d );
Cheers,
Alex
--
Gossamer Threads Inc.
Oct 8, 2000, 10:08 AM
User (113 posts)
Oct 8, 2000, 10:08 AM
Post #8 of 8
Views: 4579
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"
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"