Skip to content

Commit

Permalink
Add caching of emoji from s.w.org
Browse files Browse the repository at this point in the history
  • Loading branch information
westonruter committed Oct 16, 2020
1 parent 4b51a2b commit 2cea537
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,13 @@ public function serve( WP_Service_Worker_Scripts $scripts ) {
return;
}

$cached_base_url_patterns = array(
preg_quote( trailingslashit( includes_url() ), '/' ) . '.*',
'https?:\/\/s\.w\.org\/images\/core\/emoji\/.*',
);

$scripts->caching_routes()->register(
'^' . preg_quote( trailingslashit( includes_url() ), '/' ) . '.*',
'^(' . implode( '|', $cached_base_url_patterns ) . ')',
array(
// Even though assets should have far-future expiration, network-first is still preferred for development purposes.
'strategy' => WP_Service_Worker_Caching_Routes::STRATEGY_NETWORK_FIRST,
Expand Down

0 comments on commit 2cea537

Please sign in to comment.