From 93ea9a2976c6f0be7604c94877d7fd1a8b3ba0c6 Mon Sep 17 00:00:00 2001 From: Naz Date: Wed, 8 Mar 2023 14:16:28 +0800 Subject: [PATCH] Added a not on media inlining perf improvement refs https://github.com/TryGhost/Toolbox/issues/524 - Fetching media from a remote server is an expensive network operation. Given there's probability for the content to reuse the same image in different posts or in multiple places, we could save on extra fetches by adding caching to the remote media fetch method --- ghost/external-media-inliner/lib/ExternalMediaInliner.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ghost/external-media-inliner/lib/ExternalMediaInliner.js b/ghost/external-media-inliner/lib/ExternalMediaInliner.js index f8b84ead02..08da62816c 100644 --- a/ghost/external-media-inliner/lib/ExternalMediaInliner.js +++ b/ghost/external-media-inliner/lib/ExternalMediaInliner.js @@ -40,6 +40,8 @@ class ExternalMediaInliner { * @returns {Promise} */ async #getRemoteMedia(requestURL) { + // @NOTE: this is the most expensive operation in the whole inlining process + // we should consider caching the results to improve performance try { return await request(requestURL, { followRedirect: true,