This repository was archived by the owner on Jan 28, 2025. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 457
This repository was archived by the owner on Jan 28, 2025. It is now read-only.
Image Optimiser cache headers are not preserved #2421
Copy link
Copy link
Closed
Description
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
- Request an image via the
/_next/image
endpoint, observe correctCache-Control
header in response. - Invalidate the
/_next/image
Cloudfront cache, or await cache expiry if less than lambda instance liveness (~30min). - Request the same image, observe
Cache-Control
header is nowpublic, 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
oralpha
@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 oldserverless-next.js
component and theserverless-next.js
plugin are deprecated and no longer maintained.
Metadata
Metadata
Assignees
Labels
No labels