Skip to content

Commit 9b38b4f

Browse files
ranguardoalders
authored andcommitted
Add cdn caching to search (most hit end point, will do background revalidation and serve from cache if error)
1 parent afc1b07 commit 9b38b4f

File tree

4 files changed

+8
-1
lines changed

4 files changed

+8
-1
lines changed

lib/MetaCPAN/Web/Controller/About.pm

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ sub meta_hack : Local : Args(0) {
4040

4141
sub resources : Local : Args(0) {
4242
my ( $self, $c ) = @_;
43+
$c->browser_max_age('1y');
44+
$c->cdn_max_age('1y');
4345
$c->res->redirect( '/about/contact', 301 );
4446
$c->detach;
4547
}

lib/MetaCPAN/Web/Controller/Pod.pm

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ sub view : Private {
4040
my $release = $c->stash->{release};
4141

4242
if ( $data->{directory} ) {
43+
$c->cdn_max_age('1y');
4344
$c->res->redirect( $c->uri_for( '/source', @path ), 301 );
4445
$c->detach;
4546
}

lib/MetaCPAN/Web/Controller/Release.pm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ sub view : Private {
6565

6666
my $release = $data->{release};
6767

68-
$c->browser_max_age('1h');
68+
$c->browser_max_age('1d');
6969
$c->res->last_modified( $release->{date} );
7070
$c->cdn_max_age('1y');
7171
$c->add_dist_key( $release->{distribution} );

lib/MetaCPAN/Web/Controller/Search.pm

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,13 @@ sub index : Path : Args(0) {
1616
my $page = $req->page;
1717
my $page_size = $req->get_page_size(20);
1818

19+
# Cache searches as this is where most traffic hits
20+
$c->cdn_max_age('1d');
21+
1922
# Redirect back to main page if search query is empty irrespective of
2023
# whether we're feeling lucky or not.
2124
unless ( $req->param('q') ) {
25+
$c->browser_max_age('1w');
2226
$c->res->redirect('/');
2327
$c->detach;
2428
}

0 commit comments

Comments
 (0)