storyblok / next.js-13-boilerplate

21 stars 12 forks source link

Not getting up to date content when version is set to "draft" #2

Closed oliverstreissi closed 1 year ago

oliverstreissi commented 1 year ago

When I'm using this boilerplate I'm not getting up to date content with version set to "draft".

Expected Behavior

Should show up to date content.

Current Behavior

Seems like the content is cached, when I add cv: new Date().getTime() additionally to the SbStoriesParams in the fetchData() function of the page component, I'm getting the up to date content.

Steps to Reproduce

  1. Use this template
  2. Add your Storyblok preview token
  3. Start the dev server
  4. Try adding and updating the content -> nothing changes
  5. Switch to version: "published" or add the param mentioned above
  6. Try updating content again -> you can see the current content
arorachakit commented 1 year ago

Hey @oliverstreissi ! Sorry for the late reply, this issue is known. It is not caused by storyblok sdk, this is happening because of Next.js automatic caching. As the SDK uses fetch behind the scenes, Next.js caches the requests. Therefore by using a random cv makes the url new and the cache is not hit so get the updated content. Currently, there is no way to change the fetch parameters, but we are working on it and it should be fixed soon. Here is the pull request you can take a look at - https://github.com/storyblok/storyblok-js-client/pull/660 :)

cc - @fgiuliani