Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
small optimization
  • Loading branch information
kraih committed Aug 6, 2014
1 parent d1195cb commit 577b852
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/Mojolicious/Static.pm
Expand Up @@ -63,8 +63,9 @@ sub is_fresh {
my $matches = $match && ($res_headers->etag // '') ne $match ? 0 : 1;

# If-Modified-Since
my $last = Mojo::Date->new($res_headers->last_modified // '')->epoch;
my $unmodified = !$since || $last <= (Mojo::Date->new($since)->epoch // 0);
return $matches unless (my $last = $res_headers->last_modified) && $since;
my $unmodified
= Mojo::Date->new($last)->epoch <= (Mojo::Date->new($since)->epoch // 0);

return $matches && $unmodified;
}
Expand Down

0 comments on commit 577b852

Please sign in to comment.