From eeecfbf4a676abf8f210886f5f5142ba82e04483 Mon Sep 17 00:00:00 2001 From: Sebastian Qvarfordt Date: Thu, 3 Dec 2020 15:00:03 +0100 Subject: [PATCH] Cache techdocs build using UrlReader (#3551) * Better caching is coming when some backstage core features are in place. Currently let's just cache it for 30 minutes * Fixed prettier --- plugins/techdocs-backend/src/service/helpers.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/plugins/techdocs-backend/src/service/helpers.ts b/plugins/techdocs-backend/src/service/helpers.ts index 4a736f7388..012061dc0a 100644 --- a/plugins/techdocs-backend/src/service/helpers.ts +++ b/plugins/techdocs-backend/src/service/helpers.ts @@ -120,6 +120,16 @@ export class DocsBuilder { } } + // TODO: Better caching for URL. + if (type === 'url') { + const builtAt = buildMetadataStorage.getTimestamp(); + const now = Date.now(); + + if (builtAt > now - 1800000) { + return true; + } + } + this.logger.debug( `Docs for entity ${getEntityId(this.entity)} was outdated.`, );