Disable client side page cache on some pages
This commit is contained in:
parent
1c85884f70
commit
e26ac32903
|
@ -13,11 +13,13 @@ export const addCommonHeadersMiddleware = defineMiddleware(async ({ url }, next)
|
||||||
response.headers.set("X-Robots-Tag", "none");
|
response.headers.set("X-Robots-Tag", "none");
|
||||||
response.headers.set("Vary", "Cookie");
|
response.headers.set("Vary", "Cookie");
|
||||||
|
|
||||||
if (import.meta.env.CACHE_CONTROL !== "true") {
|
if (!response.headers.has("cache-control")) {
|
||||||
|
if (import.meta.env.CACHE_CONTROL !== "true" && !response.headers.has("cache-control")) {
|
||||||
response.headers.set("Cache-Control", "no-store");
|
response.headers.set("Cache-Control", "no-store");
|
||||||
} else {
|
} else {
|
||||||
response.headers.set("Cache-Control", "max-age=86400, stale-while-revalidate=86400");
|
response.headers.set("Cache-Control", "max-age=86400, stale-while-revalidate=86400");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return response;
|
return response;
|
||||||
});
|
});
|
||||||
|
|
|
@ -3,6 +3,8 @@ import AppLayout from "components/AppLayout/AppLayout.astro";
|
||||||
import Button from "components/Button.astro";
|
import Button from "components/Button.astro";
|
||||||
import { getI18n } from "src/i18n/i18n";
|
import { getI18n } from "src/i18n/i18n";
|
||||||
|
|
||||||
|
Astro.response.headers.set("Cache-Control", "no-store");
|
||||||
|
|
||||||
const { t, getLocalizedUrl } = await getI18n(Astro.locals.currentLocale);
|
const { t, getLocalizedUrl } = await getI18n(Astro.locals.currentLocale);
|
||||||
---
|
---
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,8 @@ import Button from "components/Button.astro";
|
||||||
import Card from "components/Card.astro";
|
import Card from "components/Card.astro";
|
||||||
import { getI18n } from "src/i18n/i18n";
|
import { getI18n } from "src/i18n/i18n";
|
||||||
|
|
||||||
|
Astro.response.headers.set("Cache-Control", "no-store");
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
error: unknown;
|
error: unknown;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
---
|
---
|
||||||
|
Astro.response.headers.set("Cache-Control", "no-store");
|
||||||
return Astro.redirect("https://discord.com/invite/5mcXcRAczj");
|
return Astro.redirect("https://discord.com/invite/5mcXcRAczj");
|
||||||
---
|
---
|
||||||
|
|
|
@ -19,6 +19,7 @@ import { Collections } from "src/shared/payload/constants";
|
||||||
import { meilisearch } from "src/services";
|
import { meilisearch } from "src/services";
|
||||||
|
|
||||||
Astro.locals.pageCaching = false;
|
Astro.locals.pageCaching = false;
|
||||||
|
Astro.response.headers.set("Cache-Control", "no-store");
|
||||||
|
|
||||||
type State = {
|
type State = {
|
||||||
q: string;
|
q: string;
|
||||||
|
|
Loading…
Reference in New Issue