Skip to content

Commit

Permalink
Merge pull request #847 from juusopiikkila/main
Browse files Browse the repository at this point in the history
feat: improve cv cache flushing
  • Loading branch information
alvarosabu authored Oct 1, 2024
2 parents b6bf941 + dd7247d commit ea68845
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -627,14 +627,13 @@ class Storyblok {
await provider.set(cacheKey, response)
}

if (response.data.cv && params.token) {
if (
params.version === 'draft' &&
cacheVersions[params.token] != response.data.cv
) {
await this.flushCache()
}
cacheVersions[params.token] = params.cv ? params.cv : response.data.cv
if (
response.data.cv
&& params.token
&& cacheVersions[params.token] != response.data.cv
) {
await this.flushCache()
cacheVersions[params.token] = response.data.cv
}

return resolve(response)
Expand Down

0 comments on commit ea68845

Please sign in to comment.