Skip to content

Commit

Permalink
test better cache strat
Browse files Browse the repository at this point in the history
  • Loading branch information
stipsan committed Dec 12, 2024
1 parent 5c0b217 commit af6d571
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions next-14/src/app/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import type {SyncTag} from '@sanity/client'
import {revalidateTag} from 'next/cache'

export async function expireTags(tags: SyncTag[]) {
revalidateTag('sanity:tags')
for (const tag of tags) {
revalidateTag(tag)
}
Expand Down
2 changes: 1 addition & 1 deletion next-14/src/sanity/fetch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export async function sanityFetch<const QueryString extends string>({
filterResponse: false,
cacheMode: 'noStale',
tag: 'fetch-sync-tags', // The request tag makes the fetch unique, avoids deduping with the cached query that has tags
next: {revalidate: 1}, // Ensure we don't opt out of ISR caching
next: {revalidate: false, tags: ['sanity:tags']}, // Ensure we don't opt out of ISR caching
})
const data = await client.fetch(query, params, {
cacheMode: 'noStale',
Expand Down
1 change: 1 addition & 0 deletions next-15/src/app/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import type {SyncTag} from '@sanity/client'
import {revalidateTag} from 'next/cache'

export async function expireTags(tags: SyncTag[]) {
revalidateTag('sanity:tags')
for (const tag of tags) {
revalidateTag(tag)
}
Expand Down
1 change: 1 addition & 0 deletions next-15/src/sanity/fetch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export async function sanityFetch<const QueryString extends string>({
filterResponse: false,
cacheMode: 'noStale',
tag: 'fetch-sync-tags', // The request tag makes the fetch unique, avoids deduping with the cached query that has tags
next: {revalidate: false, tags: ['sanity:tags']},
})
const data = await client.fetch(query, params, {
cacheMode: 'noStale',
Expand Down

0 comments on commit af6d571

Please sign in to comment.