Setting Http headers like Cache-Tags inside App Routes #95058
Unanswered
LegendAlec-M
asked this question in
Help
Replies: 2 comments 3 replies
-
|
You must be using App Router though, no? This is not a limitation of Next.js, necessarily, but streaming, headers are already sent. In Pages Router, you can do this in What is the usage at the of the day, caching in a CDN? Feels like yeah, you'd need to have a fast path in the proxy/middleware to get the data you need, preferably with a key-value store in front, to lower latency. |
Beta Was this translation helpful? Give feedback.
3 replies
This comment was marked as low quality.
This comment was marked as low quality.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Summary
Hi,
We are using App routes in our Next.js project v14. Our
page.tsxfile, calls an API endpoint with the page slug and user location as parameters to retrieve the page content. Our use case is to pick the property article_id from the API Endpoint response and set it in the HTTP Cache-Tag headere.g. Cache-Tag: article_10.
At the moment its not possible to set Http headers inside the
page.tsxfile due to limitation of next.js. We have thought about adding the API call as a middleware, however it's not in the page context in middleware or we would have to duplicate calls to the Api endpoint once in middleware and once in page.tsx.Is there a workaround that we could use at to set http headers inside the App routes (page.tsx)
Thanks in advance for you help.
Alec
Additional information
No response
Example
No response
Beta Was this translation helpful? Give feedback.
All reactions