Skip to content

Open-source manufacturing ERP, MES and QMS. Quoting, MRP, inventory, shop floor, quality and lot/serial traceability on one Postgres schema, with a REST API and MCP server. Self-host or use Carbon Cloud.

perf(erp): the browser keeps the timezone list for a day

Sidwebworks3070451ffb7e
diff --git a/apps/erp/app/routes/api+/timezones.ts b/apps/erp/app/routes/api+/timezones.ts
index de32a2d948..660bc892dd 100644
--- a/apps/erp/app/routes/api+/timezones.ts
+++ b/apps/erp/app/routes/api+/timezones.ts
@@ -5,11 +5,18 @@
import { requirePermissions } from "@carbon/auth/auth.server";
import { cachedClientLoader, RefreshRate } from "@carbon/query/cache";
import type { LoaderFunctionArgs } from "react-router";
+import { data } from "react-router";
import { getCachedTimezoneNames } from "~/modules/shared/shared.server";
export async function loader({ request }: LoaderFunctionArgs) {
const { client } = await requirePermissions(request, {});
- return await getCachedTimezoneNames(client);
+ const result = await getCachedTimezoneNames(client);
+ if (!result.data?.length) return data(result);
+ // The same list for every company, and it only changes with the database's
+ // tzdata: the browser keeps it across page loads as long as the server does.
+ return data(result, {
+ headers: { "Cache-Control": "private, max-age=86400" }
+ });
}
export const clientLoader = cachedClientLoader<typeof loader>({