You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
get info, if fetch request response is fresh or came from cache
Non-Goals
No response
Background
When logging the response of a fetch request in Next.js, we get the following information:
{
cache: 'force-cache',
next: { tags: [ '/project/tag' ] },
url: 'https://request-url',
method: 'GET',
headers: { ... }
}
As shown, the only cache-related detail available is the caching strategy itself. However, in my case I need to determine whether the data is fresh — that is, whether this was a new request or a cached response. For example, I want to record performance metrics and measure the full request duration, but only when the data is retrieved from the origin and not served from cache.
I think its main usage would be for collecting metrics or separate logic for data
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
Goals
Non-Goals
No response
Background
When logging the response of a fetch request in Next.js, we get the following information:
{
cache: 'force-cache',
next: { tags: [ '/project/tag' ] },
url: 'https://request-url',
method: 'GET',
headers: { ... }
}
As shown, the only cache-related detail available is the caching strategy itself. However, in my case I need to determine whether the data is fresh — that is, whether this was a new request or a cached response. For example, I want to record performance metrics and measure the full request duration, but only when the data is retrieved from the origin and not served from cache.
I think its main usage would be for collecting metrics or separate logic for data
Proposal
get it in separate field, or some flag in header
Beta Was this translation helpful? Give feedback.
All reactions