Skip to content

Commit 829274f

Browse files
committed
Revert "fix(qwik-city): Prevent unexpected caching for q-data.json more (#6808)"
This reverts commit b219343.
1 parent f736793 commit 829274f

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

packages/qwik-city/src/runtime/src/use-endpoint.ts

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export const loadClientData = async (
2828
let resolveFn: () => void | undefined;
2929

3030
if (!qData) {
31-
const fetchOptions = getFetchOptions(opts?.action);
31+
const fetchOptions = getFetchOptions(opts?.action, opts?.clearCache);
3232
if (opts?.action) {
3333
opts.action.data = undefined;
3434
}
@@ -88,16 +88,22 @@ export const loadClientData = async (
8888
});
8989
};
9090

91-
const getFetchOptions = (action: RouteActionValue | undefined): RequestInit => {
91+
const getFetchOptions = (
92+
action: RouteActionValue | undefined,
93+
noCache: boolean | undefined
94+
): RequestInit | undefined => {
9295
const actionData = action?.data;
9396
if (!actionData) {
94-
return {
95-
cache: 'no-cache',
96-
headers: {
97-
'Cache-Control': 'no-cache',
98-
Pragma: 'no-cache',
99-
},
100-
};
97+
if (noCache) {
98+
return {
99+
cache: 'no-cache',
100+
headers: {
101+
'Cache-Control': 'no-cache',
102+
Pragma: 'no-cache',
103+
},
104+
};
105+
}
106+
return undefined;
101107
}
102108
if (actionData instanceof FormData) {
103109
return {

0 commit comments

Comments
 (0)