Browse Source
Task/enable browser cache for logo endpoints (#7956)
* Enable browser cache
* Update changelog
pull/7904/head
Thomas Kaul
24 hours ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with
16 additions and
0 deletions
-
CHANGELOG.md
-
apps/api/src/app/logo/logo.controller.ts
|
|
|
@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 |
|
|
|
### Changed |
|
|
|
|
|
|
|
- Simplified the portfolio summary by hiding the currency on mobile |
|
|
|
- Improved the performance of the logo endpoints by enabling the browser cache |
|
|
|
- Improved the language localization for Catalan (`ca`) |
|
|
|
|
|
|
|
### Fixed |
|
|
|
|
|
|
|
@ -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(); |
|
|
|
|