Skip to content

Instantly share code, notes, and snippets.

@robhammond
Last active April 6, 2017 12:06
Show Gist options
  • Save robhammond/c78e5eae9439ea03bded9c63dd46adff to your computer and use it in GitHub Desktop.
Save robhammond/c78e5eae9439ea03bded9c63dd46adff to your computer and use it in GitHub Desktop.
Quick script to ping the AMPProject CDN and refresh cache
#!/usr/bin/env perl
use strict;
use Modern::Perl;
use Mojo::UserAgent;
# Add list of URLs into @urls array
my @urls = qw();
my $ua = Mojo::UserAgent->new;
for my $u (@urls) {
$u =~ s!^http://!!;
$u .= '.amp';
$u = 'https://cdn.ampproject.org/update-ping/c/s/' . $u;
say $u;
my $tx = $ua->get($u);
if (my $res = $tx->success) {
say $res->code;
} else {
say $res->code;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment