From 4d4d087d48dbc6b5c7e78def99857b2cfce1bc4c Mon Sep 17 00:00:00 2001 From: Thomas Kaul <4159106+dtslvr@users.noreply.github.com> Date: Sun, 27 Sep 2026 17:12:03 +0200 Subject: [PATCH] Enable browser cache --- apps/api/src/app/logo/logo.controller.ts | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/apps/api/src/app/logo/logo.controller.ts b/apps/api/src/app/logo/logo.controller.ts index 47bd1fc750..30c85e585e 100644 --- a/apps/api/src/app/logo/logo.controller.ts +++ b/apps/api/src/app/logo/logo.controller.ts @@ -11,12 +11,15 @@ import { } from '@nestjs/common'; import { DataSource } from '@prisma/client'; import { Response } from 'express'; +import ms from 'ms'; import { GetLogoDto } from './get-logo.dto'; import { LogoService } from './logo.service'; @Controller('logo') export class LogoController { + private static readonly CACHE_MAX_AGE_IN_SECONDS = ms('7 days') / 1000; + public constructor(private readonly logoService: LogoService) {} @Get(':dataSource/:symbol') @@ -34,6 +37,12 @@ export class LogoController { }); response.contentType(type); + + response.setHeader( + 'Cache-Control', + `public, max-age=${LogoController.CACHE_MAX_AGE_IN_SECONDS}` + ); + response.send(buffer); } catch { response.status(HttpStatus.NOT_FOUND).send(); @@ -49,6 +58,12 @@ export class LogoController { const { buffer, type } = await this.logoService.getLogoByUrl(url); response.contentType(type); + + response.setHeader( + 'Cache-Control', + `public, max-age=${LogoController.CACHE_MAX_AGE_IN_SECONDS}` + ); + response.send(buffer); } catch { response.status(HttpStatus.NOT_FOUND).send();