From 677152216735cba287154c7a44bd75d6eeae67e4 Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Tue, 24 Jul 2018 11:05:09 -0400 Subject: [PATCH] Reduce cache time for OEmbed error --- src/Content/OEmbed.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Content/OEmbed.php b/src/Content/OEmbed.php index 64ddc64f0..a1fe4f306 100644 --- a/src/Content/OEmbed.php +++ b/src/Content/OEmbed.php @@ -112,6 +112,7 @@ class OEmbed } $oembed->parseJSON($json_string); + if (!empty($oembed->type) && $oembed->type != 'error') { DBA::insert('oembed', [ 'url' => normalise_link($embedurl), @@ -119,9 +120,12 @@ class OEmbed 'content' => $json_string, 'created' => DateTimeFormat::utcNow() ], true); + $cache_ttl = CACHE_DAY; + } else { + $cache_ttl = CACHE_FIVE_MINUTES; } - Cache::set($cache_key, $json_string, CACHE_DAY); + Cache::set($cache_key, $json_string, $cache_ttl); } if ($oembed->type == 'error') {