From b05671cdb5db0022db525cd374e52e58b7074bcb Mon Sep 17 00:00:00 2001 From: zimbatm Date: Tue, 7 Sep 2021 11:58:30 +0200 Subject: [PATCH 1/2] set cache-control on mutable objects This allows to override the default TTL on Fastly. Let it know what these objects should be refreshed more often. Fixes NixOS/nixos-org-configurations#169 --- mirror-nixos-branch.pl | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/mirror-nixos-branch.pl b/mirror-nixos-branch.pl index ba355bd..0fbc734 100755 --- a/mirror-nixos-branch.pl +++ b/mirror-nixos-branch.pl @@ -330,11 +330,17 @@ if ($channelName =~ /20.03/ || $channelName =~ /19.09/) { run("git push channels $rev:refs/heads/$channelName >&2"); } +# s-maxage=600: Serve from cache for 5 minutes. +# stale-while-revaliadate=1800: Serve from cache while updating in the background for 30 minutes. +# 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 { my ($from, $to) = @_; $to = "https://releases.nixos.org/" . $to; 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; } From 1a2b045d2c73d35890cfe8302fae2d6173ec7dab Mon Sep 17 00:00:00 2001 From: zimbatm Date: Wed, 8 Sep 2021 19:41:10 +0200 Subject: [PATCH 2/2] mirror-nixos-branch: stop pushing to nixpkgs-channels The channel has been archived and doesn't take updates anymore. --- mirror-nixos-branch.pl | 5 ----- 1 file changed, 5 deletions(-) diff --git a/mirror-nixos-branch.pl b/mirror-nixos-branch.pl index 0fbc734..f12aa3c 100755 --- a/mirror-nixos-branch.pl +++ b/mirror-nixos-branch.pl @@ -325,11 +325,6 @@ if ($dryRun) { run("git remote update origin >&2"); run("git push origin $rev:refs/heads/$channelName >&2"); -# Also update the nixpkgs-channels repo for compatibility. -if ($channelName =~ /20.03/ || $channelName =~ /19.09/) { - run("git push channels $rev:refs/heads/$channelName >&2"); -} - # s-maxage=600: Serve from cache for 5 minutes. # stale-while-revaliadate=1800: Serve from cache while updating in the background for 30 minutes. # https://web.dev/stale-while-revalidate/