diff --git a/News.md b/News.md deleted file mode 100644 index d57e32854a..0000000000 --- a/News.md +++ /dev/null @@ -1,179 +0,0 @@ -## Title: Source code permalinks are here - -Date: 2020-03-29T00:00:00 - -Versioned permalinks from source code pages are -[now available](https://twitter.com/metacpan/status/1244677954275336200) - -## Title: Rendering .md files - -Date: 2019-10-18T01:54:00 - -We're now rendering .md files as HTML instead of as raw code. - -## Title: The traffic is coming - -Date: 2018-12-02T19:30:00 - -As -[announced](https://log.perl.org/2018/05/goodbye-search-dot-cpan-dot-org.html) -in the Perl NOC, search.cpan.org is going to redirect all traffic to MetaCPAN -from 25th of June 2018. We are doing lots of work to prepare for this trebling -of traffic. - -## Title: MetaHack 2 - -Date: 2017-11-02T19:30:00 - -http://www.olafalders.com/2017/10/12/announcing-metahack-v2/ - -https://metacpan.org/about/meta_hack - -http://blogs.perl.org/users/leo_lapworth/2017/11/metahack-2.html - -## Title: SSL improvements - -Date: 2014-12-02T19:30:00 - -Our servers have had their SSL configuration upgraded, so we now get an A rating -on -[SSL Labs](https://www.ssllabs.com/ssltest/analyze.html?d=fastapi.metacpan.org). - -[Fastly](https://www.fastly.com) who serve all our content other than the -[api](https://fastapi.metacpan.org/) already had tight configs... and now so do -we. I'd like to thank then for providing both examples, support and an IRC -channel where Donald Stufft from the Python infrastructure team was able to help -out. - -All our configs and systems are in our -[github repos](https://github.com/metacpan/) so feel free to review / improve or -'borrow' configs from. - -## Title: Liquid Web is Sponsoring MetaCPAN - -Date: 2014-11-08T03:00:00 - -We're immensely pleased to announce that -[Liquid Web Inc.](https://www.liquidweb.com/) is our newest hosting sponsor. -This sponsorship entails 3 powerful machines which are provided and co-located -by Liquid Web Inc. Having access to this hardware will allow us greater -redundancy in addition to giving us powerful machines to use as a staging area -when developing new MetaCPAN features. This is a huge development for us and -we'd like to thank Liquid Web Inc. for this very kind donation. More details to -come! - -## Title: Server move - phase 2 - -Date: 2014-10-21T19:00:00 - -We have moved all sites over to [Fastly](https://www.fastly.com) (where -possible) and they are backed up by the new -[Bytemark](https://www.bytemark.co.uk/) servers. - -We have further plans... but this will do for now, many thanks to our sponsors -for making this possible. - -[network-infrastructure](https://github.com/metacpan/network-infrastructure) and -[metacpan-puppet](https://github.com/metacpan/metacpan-puppet) have all our -configs if you want to see details of anything. - -## Title: Server move - phase 1 - -Date: 2014-09-19T19:00:00 - -We are moving servers, [Bytemark](https://www.bytemark.co.uk/) have asked for -the old one back... and given us 2 new ones in replacement! - -We are moving as much as possible to [Fastly](https://www.fastly.com) CDN which -makes switching origins very easy, and instant. - -So far we have moved... - -- http(s)://cpan.metacpan.org/ -- http://explorer.metacpan.org/ -- http://search.mcpan.org/ -- http://mcpan.org/ - -We will be documenting this a bit more under -[Network Infrastructure](https://github.com/metacpan/network-infrastructure) but -that's a work in progress. - -## Title: Let's move to Bootstrap 3 - -Date: 2014-08-06T08:55:22 - -MetaCPAN has moved to Bootstrap 3 as well as introducing cool icons from -[Font Awesome](http://fortawesome.github.io/Font-Awesome/). Let's make MetaCPAN -be more colorful! - -## Title: Link to Task::Kensho is now available on home page and no result page - -Date: 2014-06-14T23:25:11 - -If you’re absolute newbies who're not even sure what to search, it will be good -idea to take a look at [Task::Kensho!](https://metacpan.org/pod/Task::Kensho) We -provide a link to the module in both Home page and No result page with the idea -to help CPAN beginners to get started. - -## Title: Faster with Fastly - -Date: 2014-06-14T18:44:15 - -You may have noticed an increase in speed for https://metacpan.org/ since the -22nd of May, this is because the site is now served through -[Fastly](https://www.fastly.com/). Fastly are providing this service free of -charge. We are not fully utilising is yet (we don't let Fastly cache much), but -it makes all sorts of things easier for us and we will be able to do even more -for you with it in the future. - -## Title: Suggestion on incorrect number of colons - -Date: 2014-06-09T08:15:00 - -Perl module name should contain only 2 colons, some common mistakes are we -underuse or overuse it. Now, suggestion on no result page available when search -with missing colon such as -[Test:More](https://metacpan.org/search?q=Test%3AMore) or too much colons like -[DBIx:::Class::::ResultSet](https://metacpan.org/search?q=DBIx%3A%3A%3AClass%3A%3A%3A%3AResultSet). - -## Title: Table sorting is now persistent - -Date: 2014-05-19T10:50:12 - -When you change the sorting of a table it will be saved in your browser's -localStorage so that the next time you view that particular table it will -remember your last preference. This is saved on a per table basis (for example, -author releases, author favorites, and reverse dependency releases). No need to -set it every time when accessing that page in the same browser. - -## Title: Details of (++)plussers displayed - -Date: 2014-05-12T18:40:17 - -To get a better insight of which Pause users have ++ed a particular -distribution, a list of their gravatar images is displayed. Also, the count of -non-Pause plussers makes it easier to know how many users have liked the module. - -Hence, it gives us a perception of the people who recommend the module. - -## Title: Dependency Graphs are Here - -Date: 2014-05-13T20:50:10 - -Jeffrey Thalhammer took the time this week to contribute dependency graphs to -MetaCPAN. The graphs are hosted by [Stratopan](https://stratopan.com) and they -can be found on module and release pages under the "Reverse Dependencies" link. - -Thanks very much to [THALJEF](https://metacpan.org/author/THALJEF) for -implementing this new feature. - -## Title: News feed of MetaCPAN created - -Date: 2014-04-15T21:10:10 - -In this news feed you can follow the development of the MetaCPAN site. There is -also an [Atom feed](/feed/news). - -If you are interested in how the news feed itself was implemented, check out the -article -[Adding a News Feed to MetaCPAN](https://perlmaven.com/adding-news-feed-to-metacpan) diff --git a/lib/MetaCPAN/Middleware/OldUrls.pm b/lib/MetaCPAN/Middleware/OldUrls.pm index e3420a2f4c..d98e824be0 100644 --- a/lib/MetaCPAN/Middleware/OldUrls.pm +++ b/lib/MetaCPAN/Middleware/OldUrls.pm @@ -70,7 +70,6 @@ sub _routes { ( [ '/permission/module/:module', '/module/:module/permissions' ], [ '/feed/recent', '/recent.:type', $feed_type ], - [ '/feed/news', '/news.:type', $feed_type ], [ '/feed/author/:author', '/author/:author/activity.:type', $feed_type ], [ '/feed/distribution/:dist', '/dist/:dist/releases.:type', $feed_type ], diff --git a/lib/MetaCPAN/Web/Controller/About.pm b/lib/MetaCPAN/Web/Controller/About.pm index d33d6c739a..fb06318690 100644 --- a/lib/MetaCPAN/Web/Controller/About.pm +++ b/lib/MetaCPAN/Web/Controller/About.pm @@ -38,12 +38,6 @@ sub meta_hack : Local : Args(0) { my ( $self, $c ) = @_; } -sub resources : Local : Args(0) { - my ( $self, $c ) = @_; - $c->res->redirect( '/about/contact', 301 ); - $c->detach; -} - sub sponsors : Local : Args(0) { my ( $self, $c ) = @_; } diff --git a/lib/MetaCPAN/Web/Controller/Feed.pm b/lib/MetaCPAN/Web/Controller/Feed.pm index cb3abd22b9..33d3ed50a6 100644 --- a/lib/MetaCPAN/Web/Controller/Feed.pm +++ b/lib/MetaCPAN/Web/Controller/Feed.pm @@ -10,7 +10,6 @@ use HTML::Escape qw( escape_html ); use MetaCPAN::Web::RenderUtil qw( render_markdown ); use MetaCPAN::Web::Types qw( ArrayRef DateTime Enum HashRef Str Undef Uri ); use Params::ValidationCompiler qw( validation_for ); -use Path::Tiny qw( path ); use XML::FeedPP (); ## no perlimports use URI (); @@ -59,61 +58,6 @@ sub recent : Private { ); } -sub news_rss : Path('/news.rss') Args(0) { - my ( $self, $c ) = @_; - $c->detach( 'news', ['rss'] ); -} - -sub news_atom : Path('/news.atom') Args(0) { - my ( $self, $c ) = @_; - $c->detach( 'news', ['atom'] ); -} - -sub news : Private { - my ( $self, $c, $type ) = @_; - - $c->add_surrogate_key('NEWS'); - $c->browser_max_age('1h'); - $c->cdn_max_age('1h'); - - my $file = $c->config->{home} . '/News.md'; - my $news = path($file)->slurp_utf8; - $news =~ s/^\s+|\s+$//g; - my @entries; - foreach my $str ( split /^Title:\s*/m, $news ) { - next if $str =~ /^\s*$/; - - my %e; - $e{name} = $str =~ s/\A(.+)$//m ? $1 : 'No title'; - - # Use the same processing as _Header2Label in - # Text::MultiMarkdown - my $a_name = lc $e{name}; - $a_name =~ s/[^A-Za-z0-9:_.-]//g; - $a_name =~ s/^[^a-z]+//gi; - - $str =~ s/\A\s*-+//g; - $e{date} = $str =~ s/^Date:\s*(.*)$//m ? $1 : '2014-01-01T00:00:00'; - $e{link} = '/news'; - $e{fragment} = $a_name; - $e{author} = 'METACPAN'; - $str =~ s/^\s*|\s*$//g; - - #$str =~ s{\[([^]]+)\]\(([^)]+)\)}{$1}g; - $e{abstract} = $str; - $e{abstract} = render_markdown($str); - - push @entries, \%e; - } - - $c->stash->{feed} = $self->build_feed( - format => $type, - entries => \@entries, - host => $c->config->{web_host}, - title => 'Recent MetaCPAN News', - ); -} - sub author_rss : Chained('/author/root') PathPart('activity.rss') Args(0) { $_[1]->detach( 'author', ['rss'] ); } @@ -304,6 +248,15 @@ sub end : Private { my $feed = $c->stash->{feed}; $c->detach('/end') if !$feed; + +# This will only affect if `cdn_max_age` has been set. +# https://www.fastly.com/documentation/guides/concepts/edge-state/cache/stale/ +# If it has then do revalidation in the background + $c->cdn_stale_while_revalidate('1d'); + + # And if there is still an error serve from cache + $c->cdn_stale_if_error('1y'); + $c->res->content_type( $feed->isa('XML::FeedPP::Atom') ? 'application/atom+xml; charset=UTF-8' diff --git a/lib/MetaCPAN/Web/Controller/News.pm b/lib/MetaCPAN/Web/Controller/News.pm deleted file mode 100644 index 266c690ca8..0000000000 --- a/lib/MetaCPAN/Web/Controller/News.pm +++ /dev/null @@ -1,24 +0,0 @@ -package MetaCPAN::Web::Controller::News; - -use Moose; - -BEGIN { extends 'MetaCPAN::Web::Controller' } - -use Path::Tiny qw( path ); - -sub news : Path : Args(0) { - my ( $self, $c ) = @_; - - my $file = $c->config->{home} . '/News.md'; - my $news = path($file)->slurp_utf8; - $news =~ s/^Title:\s*//gm; - - $c->stash( { - news => $news, - template => 'news.tx', - } ); -} - -__PACKAGE__->meta->make_immutable; - -1; diff --git a/lib/MetaCPAN/Web/Controller/Pod.pm b/lib/MetaCPAN/Web/Controller/Pod.pm index bb683bfd1a..6d606b8f6b 100644 --- a/lib/MetaCPAN/Web/Controller/Pod.pm +++ b/lib/MetaCPAN/Web/Controller/Pod.pm @@ -40,6 +40,10 @@ sub view : Private { my $release = $c->stash->{release}; if ( $data->{directory} ) { + +# This can end up being a redirect from a non-versioned path to a versioned path +# and it doesn't have any surrogate keys so it won't get purged. + $c->cdn_max_age('1d'); $c->res->redirect( $c->uri_for( '/source', @path ), 301 ); $c->detach; } diff --git a/lib/MetaCPAN/Web/Controller/Release.pm b/lib/MetaCPAN/Web/Controller/Release.pm index 56c62a4314..8c662ac1a5 100644 --- a/lib/MetaCPAN/Web/Controller/Release.pm +++ b/lib/MetaCPAN/Web/Controller/Release.pm @@ -65,7 +65,7 @@ sub view : Private { my $release = $data->{release}; - $c->browser_max_age('1h'); + $c->browser_max_age('1d'); $c->res->last_modified( $release->{date} ); $c->cdn_max_age('1y'); $c->add_dist_key( $release->{distribution} ); diff --git a/lib/MetaCPAN/Web/Controller/Root.pm b/lib/MetaCPAN/Web/Controller/Root.pm index cb4c1f2653..2ddf52c0b6 100644 --- a/lib/MetaCPAN/Web/Controller/Root.pm +++ b/lib/MetaCPAN/Web/Controller/Root.pm @@ -113,6 +113,14 @@ Attempt to render a view, if needed. sub end : ActionClass('RenderView') { my ( $self, $c ) = @_; +# This will only affect if `cdn_max_age` has been set. +# https://www.fastly.com/documentation/guides/concepts/edge-state/cache/stale/ +# If it has then do revalidation in the background + $c->cdn_stale_while_revalidate('1d'); + + # And if there is still an error serve from cache + $c->cdn_stale_if_error('1y'); + # for normal errors, try to render the internal_error page rather my @error = @{ $c->error }; if ( @error && !$c->debug ) { diff --git a/lib/MetaCPAN/Web/Controller/Search.pm b/lib/MetaCPAN/Web/Controller/Search.pm index 9754e43066..140a29730b 100644 --- a/lib/MetaCPAN/Web/Controller/Search.pm +++ b/lib/MetaCPAN/Web/Controller/Search.pm @@ -16,9 +16,13 @@ sub index : Path : Args(0) { my $page = $req->page; my $page_size = $req->get_page_size(20); + # Cache searches as this is where most traffic hits + $c->cdn_max_age('1d'); + # Redirect back to main page if search query is empty irrespective of # whether we're feeling lucky or not. unless ( $req->param('q') ) { + $c->browser_max_age('1w'); $c->res->redirect('/'); $c->detach; } diff --git a/root/news.tx b/root/news.tx deleted file mode 100644 index d58fe1b0f6..0000000000 --- a/root/news.tx +++ /dev/null @@ -1,32 +0,0 @@ -%% cascade base { -%% title => $title || 'News', -%% rss => $rss || '/news.rss', -%% rss_title => $rss_title || 'Recent MetaCPAN News', -%% } - -%% override left_nav_classes -> { 'nav nav-pills nav-stacked' } -%% override left_nav_content -> { -[%- -for [ - [ 'About MetaCPAN', '/about' ], - [ 'grep::cpan', 'https://grep.metacpan.org/' ], - [ 'Recent', '/recent' ], - [ 'News', '/news' ], - [ 'FAQ', '/about/faq' ], - [ 'Tools', '/tools' ], - [ 'API', 'https://github.com/metacpan/metacpan-api/blob/master/docs/API-docs.md' ], - [ 'Contact', '/about/contact' ], -] -> $l { -%] -