The following script test.pl
downloads 02packages.details.txt.gz from cpan.metacpan.org 5 times
with HTTP::Tiny->mirror.
#!/usr/bin/env perl
use strict;
use warnings;
use HTTP::Tiny;
use IO::Socket::SSL;
my $http = HTTP::Tiny->new;
my $url = "https://cpan.metacpan.org/modules/02packages.details.txt.gz";
# my $url = "https://www.cpan.org/modules/02packages.details.txt.gz";
my $file = "02packages.details.txt.gz";
unlink $file;
for my $times (1..5) {
my $res = $http->mirror($url => $file);
warn "$times: $res->{status} $res->{reason}";
}
I expect that the first download returns 200 OK
, and the others return 304 Not Modified
:
❯ perl test.pl
1: 200 OK at test.pl line 17.
2: 304 Not Modified at test.pl line 17.
3: 304 Not Modified at test.pl line 17.
4: 304 Not Modified at test.pl line 17.
5: 304 Not Modified at test.pl line 17.
But, actually it returns 200 OK
several times:
❯ perl test.pl
1: 200 OK at test.pl line 17.
2: 304 Not Modified at test.pl line 17.
3: 200 OK at test.pl line 17.
4: 200 OK at test.pl line 17.
5: 200 OK at test.pl line 17.
Can you check cpan.metacpan.org or fastly setting?
Please note that if I change the url to www.cpan.org
, it returns expected responses.