Skip to content

Commit 4ede1f5

Browse files
committed
Revert "fix: add cache header for cachedFetch"
This reverts commit fe1fd2d.
1 parent 1104f71 commit 4ede1f5

1 file changed

Lines changed: 5 additions & 19 deletions

File tree

app/composables/useCachedFetch.ts

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import { type CachedFetchResult, FETCH_CACHE_DEFAULT_TTL } from '#shared/utils/fetch-cache-config'
2-
import defu from 'defu'
1+
import type { CachedFetchResult } from '#shared/utils/fetch-cache-config'
32

43
/**
54
* Get the cachedFetch function from the current request context.
@@ -31,20 +30,13 @@ import defu from 'defu'
3130
*/
3231
export function useCachedFetch(): CachedFetchFunction {
3332
// On client, return a function that just uses $fetch (no caching, not stale)
34-
3533
if (import.meta.client) {
3634
return async <T = unknown>(
3735
url: string,
3836
options: Parameters<typeof $fetch>[1] = {},
39-
ttl: number = FETCH_CACHE_DEFAULT_TTL,
37+
_ttl?: number,
4038
): Promise<CachedFetchResult<T>> => {
41-
const defaultFetchOptions: Parameters<typeof $fetch>[1] = {
42-
headers: {
43-
'Cache-Control': `max-age=${ttl}, must-revalidate`,
44-
},
45-
}
46-
47-
const data = (await $fetch<T>(url, defu(options, defaultFetchOptions))) as T
39+
const data = (await $fetch<T>(url, options)) as T
4840
return { data, isStale: false, cachedAt: null }
4941
}
5042
}
@@ -63,15 +55,9 @@ export function useCachedFetch(): CachedFetchFunction {
6355
return async <T = unknown>(
6456
url: string,
6557
options: Parameters<typeof $fetch>[1] = {},
66-
ttl: number = FETCH_CACHE_DEFAULT_TTL,
58+
_ttl?: number,
6759
): Promise<CachedFetchResult<T>> => {
68-
const defaultFetchOptions: Parameters<typeof $fetch>[1] = {
69-
headers: {
70-
'Cache-Control': `max-age=${ttl}, must-revalidate`,
71-
},
72-
}
73-
74-
const data = (await $fetch<T>(url, defu(options, defaultFetchOptions))) as T
60+
const data = (await $fetch<T>(url, options)) as T
7561
return { data, isStale: false, cachedAt: null }
7662
}
7763
}

0 commit comments

Comments
 (0)