File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -14,13 +14,20 @@ import { optimizedFetch } from './simpleFetch'
1414export const IS_FETCH_OPTIMIZED =
1515 process . env . NEXT_PUBLIC_OPTIMIZED_SANITY_FETCH === 'true'
1616
17+ const cachedSanityFetch : DefinedFetchType = async options => {
18+ 'use cache'
19+ return sanityFetch ( options )
20+ }
21+
1722export const routeSanityFetch : DefinedFetchType = async options => {
18- if ( ! IS_FETCH_OPTIMIZED ) {
23+ // Drafts must stay uncached and keep stega/visual editing support.
24+ const { isEnabled : isDraft } = await draftMode ( )
25+
26+ if ( isDraft ) {
1927 return sanityFetch ( options )
2028 }
2129
22- // drafts must stay uncached and keep stega/visual editing support
23- const { isEnabled : isDraft } = await draftMode ( )
24-
25- return isDraft ? sanityFetch ( options ) : optimizedFetch ( options )
30+ return IS_FETCH_OPTIMIZED
31+ ? optimizedFetch ( options )
32+ : cachedSanityFetch ( options )
2633}
You can’t perform that action at this time.
0 commit comments