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