perl-docs-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Randy Kobes <ra...@theoryx5.uwinnipeg.ca>
Subject Re: site mirrors
Date Tue, 03 Dec 2002 16:31:53 GMT
On Tue, 3 Dec 2002, Stas Bekman wrote:

> So I see that Randy has put up a fully functional mirror of 
> perl.apache.org: http://theoryx5.uwinnipeg.ca/modperl/index.html
> which is very fast (faster than perl.apache.org :). How often does it 
> get updated Randy?

I do it once a day, including regenerating the swish-e indices.

> Do we have any other mirrors already? I remember Thomas was talking 
> about making one.
> 
> Even though I was reluctant to having mirrors page, we probably should 
> have one for official mirrors. As long as we make sure that the listed 
> mirrors are up-to-date and perform a full-mirror. You can't imagine how 
> many outdated copies of the mod_perl guide can be found on the web. Some 
> of them are 3 years old :(

There was talk earlier of making up a script to fetch some
oft-changed page from perl.apache.org (the top-level index.html?)
and compare the time-stamp with that of a mirror. Here's a
start:

=================================================================
use strict;
use warnings;
use LWP::UserAgent;
use HTTP::Date;
my $master = 'perl.apache.org';
my $master_time = last_modified($master);
while (<DATA>) {
  chomp;
  my $mirror_time;
  unless ($mirror_time = last_modified($_)) {
    warn "Cannot get Last-Modified time for $_\n";
    next;
  }
  my $diff = ($master_time - $mirror_time) / 86400;
  printf("%s is %.2f days out of sync\n", $_, $diff) if ($diff > 0);
}

sub last_modified {
  my $site = shift;
  my $ua = LWP::UserAgent->new();
  my $req = HTTP::Request->new(HEAD => "http://$site/index.html");
  my $res = $ua->request($req);
  if ($res->is_success) {
    $res->headers_as_string =~ m!(Last-Modified: )(.*)!;
    my $time = str2time($2);
    unless ($time) {
      warn "Couldn't determine Last-Modified time for $site\n";
      return undef;
    }
    return $time;
  }
  else {
    warn ("Error for $site: " . $res->status_line . "\n");
    return undef;
  }
}

__DATA__
theoryx5.uwinnipeg.ca/modperl

=============================================================
-- 
best regards,
randy


---------------------------------------------------------------------
To unsubscribe, e-mail: docs-dev-unsubscribe@perl.apache.org
For additional commands, e-mail: docs-dev-help@perl.apache.org


Mime
View raw message