Implemented &My::Web::no_cache with $W->{"no_cache"}.
authorshort <>
Tue, 26 Oct 2004 07:55:02 +0000 (07:55 +0000)
committershort <>
Tue, 26 Oct 2004 07:55:02 +0000 (07:55 +0000)
Web.pm

diff --git a/Web.pm b/Web.pm
index 5709a63..2dd7747 100644 (file)
--- a/Web.pm
+++ b/Web.pm
@@ -75,6 +75,7 @@ require HTTP::BrowserDetect;
 require HTTP::Negotiate;
 my $have_Geo_IP; BEGIN { $have_Geo_IP=eval { require Geo::IP; 1; }; }
 use ModPerl::Util qw(exit);
+use POSIX qw(strftime);
 
 
 #our $W;
@@ -607,6 +608,16 @@ my(@arr)=@_;
        return @r;
 }
 
+sub no_cache($)
+{
+my($self)=@_;
+
+       header("Expires"=>"Mon, 26 Jul 1997 05:00:00 GMT");     # date in the past
+       header("Last-Modified"=>strftime("%a, %d %b %Y %H:%M:%S GMT",gmtime()));        # always modified
+       header("Cache-Control"=>"no-cache, must-revalidate");   # HTTP/1.1
+       header("Pragma"=>"no-cache");   # HTTP/1.0
+}
+
 sub heading ()
 {
 my($class)=@_;
@@ -617,6 +628,7 @@ my($class)=@_;
        my $client_charset=$W->{"force_charset"} || "us-ascii";
        header("Content-Style-Type"=>"text/css");
        header("Content-Script-Type"=>"text/javascript");
+       $class->no_cache() if $W->{"no_cache"};
 
        while (my($key,$val)=each(%{$W->{"headers"}})) {
                $W->{"r"}->header_out($key,$val);