Skip to content

Open-source status page, incident response and uptime monitoring

fix: tb homepage cache (#273)

Maximilian Kaskea22c2c6b58a2
diff --git a/apps/web/src/app/page.tsx b/apps/web/src/app/page.tsx
index 1e063ceca..b513cfd13 100644
--- a/apps/web/src/app/page.tsx
+++ b/apps/web/src/app/page.tsx
@@ -9,12 +9,12 @@ import { Plans } from "@/components/marketing/plans";
import { Tracker } from "@/components/tracker";
import { Badge } from "@/components/ui/badge";
import { Button } from "@/components/ui/button";
-import { getMonitorListData } from "@/lib/tb";
+import { getHomeMonitorListData } from "@/lib/tb";
export const revalidate = 600;
export default async function Page() {
- const data = await getMonitorListData({ monitorId: "openstatusPing" });
+ const data = await getHomeMonitorListData();
return (
<MarketingLayout>
diff --git a/apps/web/src/lib/tb.ts b/apps/web/src/lib/tb.ts
index 73095ebc9..6121d34ca 100644
--- a/apps/web/src/lib/tb.ts
+++ b/apps/web/src/lib/tb.ts
@@ -3,6 +3,7 @@ import type {
ResponseListParams,
} from "@openstatus/tinybird";
import {
+ getHomeMonitorList,
getMonitorList,
getResponseList,
Tinybird,
@@ -36,3 +37,13 @@ export async function getMonitorListData(props: Partial<MonitorListParams>) {
}
return;
}
+
+export async function getHomeMonitorListData() {
+ try {
+ const res = await getHomeMonitorList(tb)({ monitorId: "openstatusPing" });
+ return res.data;
+ } catch (e) {
+ console.error(e);
+ }
+ return;
+}
diff --git a/packages/tinybird/src/client.ts b/packages/tinybird/src/client.ts
index 6e6b5f924..da1599dd5 100644
--- a/packages/tinybird/src/client.ts
+++ b/packages/tinybird/src/client.ts
@@ -39,3 +39,19 @@ export function getMonitorList(tb: Tinybird) {
},
});
}
+
+/**
+ * That pipe is used in the homepage to show the status while having cached data
+ * FYI We had 3TB of processed data during August. We will be able to reduce it signifcantly.
+ * The cache is only applied on the homepage.
+ */
+export function getHomeMonitorList(tb: Tinybird) {
+ return tb.buildPipe({
+ pipe: "monitor_list__v0",
+ parameters: tbParameterMonitorList,
+ data: tbBuildMonitorList,
+ opts: {
+ revalidate: 600, // 10 minutes cache
+ },
+ });
+}