-
-
Notifications
You must be signed in to change notification settings - Fork 20
Description
Describe the bug
When I add a http header to a page, the header is added to the page request but not to the RSC request.
This is specifically a problem for HTTP Cache headers which define how long a content can be cached on the client side and at the proxy (CDN).
I am not sure if there are other header which need to be set on RSC streams. Maybe a simple optional option {"rsc":true} on the existing function could solve this:
headers(
{ "Cache-Control": "s-maxage=1" } ,
{"rsc":true}
);Or maybe a specific cacheHeader function?
It looks like you currently merge the new entry to the existing one as the result is:
Cache-Control: must-revalidate, s-maxage=1
Maybe a second option to define this would help to replace the must-revalidate:
headers({
"Cache-Control": "s-maxage=1",
},{"replace":true});Reproduction
https://d53oahuh7w7td.cloudfront.net/s/page/hello
Steps to reproduce
- add a cache header to a non static page:
import { headers } from "@lazarv/react-server";
export default async function HelloPage() {
headers({
"Cache-Control": "s-maxage=1",
});
return (-
request the page e.g. https://d53oahuh7w7td.cloudfront.net/s/page/hello - this is OK:

-
go to an other page and come back - or load this url:

System Info
System:
OS: macOS 15.2
CPU: (12) arm64 Apple M4 Pro
Memory: 3.07 GB / 48.00 GB
Shell: 5.9 - /bin/zsh
Binaries:
Node: 23.4.0 - /opt/homebrew/bin/node
Yarn: 1.22.22 - /opt/homebrew/bin/yarn
npm: 10.9.2 - /opt/homebrew/bin/npm
pnpm: 9.15.0 - /opt/homebrew/bin/pnpm
bun: 1.1.40 - /opt/homebrew/bin/bun
Browsers:
Chrome: 131.0.6778.140
Safari: 18.2
Safari Technology Preview: 18.2
npmPackages:
@lazarv/react-server: workspace:^ => 0.0.0
@lazarv/react-server-adapter-aws: workspace:^ => 0.0.0Used Package Manager
pnpm
Logs
No response
Validations
- Follow our Code of Conduct
- Read the Contributing Guidelines.
- Read the docs.
- Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
- Check that this is a concrete bug. For Q&A open a GitHub Discussion.
- The provided reproduction is a minimal reproducible example of the bug.