Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Published responses cached regardless of caching settings #952

Open
1 task done
nathobson opened this issue Oct 22, 2024 · 2 comments
Open
1 task done

Published responses cached regardless of caching settings #952

nathobson opened this issue Oct 22, 2024 · 2 comments
Labels
pending-author [Issue] Awaiting further information or action from the issue author pending-triage [Issue] Ticket is pending to be prioritised

Comments

@nathobson
Copy link

nathobson commented Oct 22, 2024

Describe the issue you're facing

Responses from the Storyblok API are cached when retrieving published content, even when apiOptions contains a cache type of none.

Reproduction

https://stackblitz.com/edit/withastro-astro-971qsd?file=.env

Steps to reproduce

Using Astro in SSR mode via output: 'server' and the Node adapter in mode: standalone, responses from the Storyblok API are cached when retrieving published content, even when apiOptions contains a cache type of none.

For example, the following call via useStoryblok() will return the cached response, not reflecting any updated (published) content:

const story = await useStoryblok(`cdn/stories/home`, {
    version: "published",
  }
)

I've also tested with the settings as in playground-ssr in the repo, which has the following settings:

apiOptions: {
  cache: {
    clear: "auto",
    type: "memory",
  },
}

This produced the same result.

However, if the exact same useStoryblok() call is set to retrieve drafts, everything updates when the page is refreshed, including draft and published content:

const story = await useStoryblok(`cdn/stories/home`, {
    version: "draft",
  }
)

There appears to be a closed and merged PR from three weeks ago in the storyblok-js-client repo but for whatever reason, this doesn't seem to have fixed the issue in the Storyblok Astro SDK.

Tested with the latest release (v5.0.2) of @storyblok/astro, which appears to contain the latest release of storyblok/storyblok-js-client from looking at the version installed in node_modules.

System Info

System:
    OS: macOS 15.0.1
    CPU: (10) arm64 Apple M1 Pro
    Memory: 66.47 MB / 16.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 20.12.2 - ~/.nvm/versions/node/v20.12.2/bin/node
    npm: 10.5.0 - ~/.nvm/versions/node/v20.12.2/bin/npm
    bun: 1.0.22 - ~/.bun/bin/bun
  Browsers:
    Brave Browser: 130.1.71.114
    Chrome: 129.0.6668.103
    Safari: 18.0.1
    Safari Technology Preview: 18.0

Used Package Manager

npm

Error logs (Optional)

No response

Validations

@nathobson nathobson added pending-author [Issue] Awaiting further information or action from the issue author pending-triage [Issue] Ticket is pending to be prioritised labels Oct 22, 2024
@J05HI
Copy link

J05HI commented Dec 20, 2024

Any news here @dipankarmaikap ?

I am using the new content layer feature and getting the same problem.
If I unpublish a page it is still in the collection. I have disabled the cache.
Here's my content/config:

import {storyblokLoader} from '@storyblok/astro';
import {defineCollection} from 'astro:content';
import StoryblokApi from '../utils/StoryblokApi';


const storyblokCollection = defineCollection({
    loader: storyblokLoader({
        accessToken: import.meta.env.STORYBLOK_TOKEN,
        version: StoryblokApi.getVersion(),
        apiOptions: {
            cache: {
                type: 'none',
            },
        },
    }),
});

export const collections = {
    storyblok: storyblokCollection,
};

@J05HI
Copy link

J05HI commented Dec 20, 2024

Replacing the same asset with a new version (for example when using the storyblok web image editor) the cache does not get refreshed too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pending-author [Issue] Awaiting further information or action from the issue author pending-triage [Issue] Ticket is pending to be prioritised
Projects
None yet
Development

No branches or pull requests

2 participants