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
After enabling fetch logs in the next.config, I noticed that the cached result from API calls using the extended native fetch is always invalidated with the message: Cache skipped reason: (cache-control: no-cache (hard refresh)) when fetching any API endpoint from a page.
Make a request from a page to an API endpoint using the native fetch (setting a cache time).
Additional context
With the server-side configuration using the posthog-node package, the problem doesn't occur, but it's not possible to use session replays.
The pages are server-side rendered, and I'm using the client provider to wrap them. Could that be the problem?
My layout is a server component, so I can't import the PostHogPageView using dynamic with ssr: false as stated in the documentation:
// Layout: without dynamic importing of PostHogPageViewimport{PostHogClientProvider}from'@src/app/providers'// irrelevant code<PostHogClientProviderisProduction={isProduction}><Suspensefallback={null}><PostHogPageView/></Suspense>{children}</PostHogClientProvider>
Even when importing the PostHogPageView dynamically inside the provider, the behavior remains the same:
// Provider: with dynamic importing of PostHogPageView'use client'import{useEffect}from'react'importdynamicfrom'next/dynamic'importposthogfrom'posthog-js'import{PostHogProvider}from'posthog-js/react'constPostHogPageView=dynamic(()=>import('@components/PostHogPageView'),{ssr: false,})constPOSTHOG_KEY=process.env.NEXT_PUBLIC_POSTHOG_KEYconstPOSTHOG_HOST=process.env.NEXT_PUBLIC_POSTHOG_HOSTexportdefaultfunctionPostHogClientProvider({ children, isProduction }){useEffect(()=>{if(isProduction){posthog.init(POSTHOG_KEY,{api_host: POSTHOG_HOST,person_profiles: 'identified_only',capture_pageview: false,capture_pageleave: true,})}},[])returnisProduction ? (<PostHogProviderclient={posthog}><PostHogPageView/>{children}</PostHogProvider>) : (children)}
The text was updated successfully, but these errors were encountered:
Bug Description
After enabling fetch logs in the
next.config
, I noticed that the cached result from API calls using the extended native fetch is always invalidated with the message:Cache skipped reason: (cache-control: no-cache (hard refresh))
when fetching any API endpoint from a page.I'm using
"next": "15.0.3"
with the app folder and followed the PostHog documentation on using the client.The result is always fresh when hitting the same endpoint multiple times:
However, it should be the cached result:
How to reproduce
next.config
.Additional context
posthog-node
package, the problem doesn't occur, but it's not possible to use session replays.layout
is a server component, so I can't import thePostHogPageView
usingdynamic
withssr: false
as stated in the documentation:PostHogPageView
dynamically inside the provider, the behavior remains the same:The text was updated successfully, but these errors were encountered: