Skip to content
This repository was archived by the owner on Jan 28, 2025. It is now read-only.
This repository was archived by the owner on Jan 28, 2025. It is now read-only.

Image Optimiser cache headers are not preserved #2421

@Peterbyte

Description

@Peterbyte

Issue Summary

When images are initially requested via _next/image, the Cache-Control header is returned as a response header. If the CDN cache expires or is invalidated, and the image is served from the lambda /tmp file system, the default cache control headers are used.

Actual behavior

The imageOptimiser route (_next/image) only forwards the Cache-Control header from the upstream when the file is initially retrieved. When the image is subsequently served from the file system cache, the default Cache-Control value public, max-age=60 is returned.

Expected behavior

The original cache headers from the origin should be preserved, no matter the state of the file system cache.

Steps to reproduce

  1. Request an image via the /_next/image endpoint, observe correct Cache-Control header in response.
  2. Invalidate the /_next/image Cloudfront cache, or await cache expiry if less than lambda instance liveness (~30min).
  3. Request the same image, observe Cache-Control header is now public, max-age=60

Versions

  • OS/Environment: Linux/WSL 4.19.104-microsoft-standard
  • @sls-next/serverless-component version: 3.7.0
  • Next.js version: 12.1.0

Additional context

Checklist

  • You have reviewed the README and FAQs, which answers several common questions.
  • You have reviewed our DEBUGGING wiki and have tried your best to include complete information and reproduction steps (including your configuration) as is possible. As there is only one maintainer (who maintains this in his free time) and thus very limited resources, if you have time, please try to debug the issue a bit yourself if possible.
  • You have first tried using the most recent latest or alpha @sls-next/serverless-component release version, which may have already fixed your issue or implemented the feature you are trying to use. Note that the old serverless-next.js component and the serverless-next.js plugin are deprecated and no longer maintained.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions