Skip to content

πŸ’Έ Perf - Raise minimumCacheTTL so optimised images are cacheableΒ #4902

Description

@joshbermanssw

Sub-issue of the AI for Business Leaders performance PBI. Fully isolated one-line change β€” can be picked up at any point.

Description

next.config.mjs sets:

images: {
  minimumCacheTTL: 60,
  ...
}

Every /_next/image response therefore carries a 60-second cache lifetime. This is Lighthouse's "Use efficient cache lifetimes β€” Est savings of 246 KiB": repeat visitors and multi-page sessions re-download every optimised image.

Proposed solution

Raise minimumCacheTTL to a long value (a year, 31536000, is the usual choice). Image URLs are keyed on the source path plus width and quality, so a content change means a new upload path from Tina and a new URL β€” a long TTL is safe.

Check at the same time whether the CDN/host in front of the app is overriding the header, in which case it needs the same treatment.

Acceptance criteria

  1. /_next/image responses carry a long Cache-Control max-age
  2. Lighthouse's "Use efficient cache lifetimes" no longer lists optimised images
  3. Replacing an image in Tina still shows the new image without a manual purge

Metadata

Metadata

Labels

Type: RefactorA code quality improvement e.g. Tech debt

Type

No type

Projects

Status
πŸ€·β€β™‚οΈ Needs Triage

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions