Merge pull request #49 from NixOS/channels-cache-control

set cache-control on mutable objects
This commit is contained in:
Jonas Chevalier 2021-09-08 20:49:15 +02:00 committed by GitHub
commit 4587d77d92
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -325,16 +325,17 @@ if ($dryRun) {
run("git remote update origin >&2"); run("git remote update origin >&2");
run("git push origin $rev:refs/heads/$channelName >&2"); run("git push origin $rev:refs/heads/$channelName >&2");
# Also update the nixpkgs-channels repo for compatibility. # s-maxage=600: Serve from cache for 5 minutes.
if ($channelName =~ /20.03/ || $channelName =~ /19.09/) { # stale-while-revaliadate=1800: Serve from cache while updating in the background for 30 minutes.
run("git push channels $rev:refs/heads/$channelName >&2"); # https://web.dev/stale-while-revalidate/
} # https://developer.fastly.com/learning/concepts/cache-freshness/
my $cache_control = "s-maxage=600,stale-while-revalidate=1800,public";
sub redirect { sub redirect {
my ($from, $to) = @_; my ($from, $to) = @_;
$to = "https://releases.nixos.org/" . $to; $to = "https://releases.nixos.org/" . $to;
print STDERR "redirect $from -> $to\n"; print STDERR "redirect $from -> $to\n";
$bucketChannels->add_key($from, "", { "x-amz-website-redirect-location" => $to }) $bucketChannels->add_key($from, "", { "x-amz-website-redirect-location" => $to, "cache-control" => $cache_control })
or die $bucketChannels->err . ": " . $bucketChannels->errstr; or die $bucketChannels->err . ": " . $bucketChannels->errstr;
} }