Skip to content

Commit 517962f

Browse files
committed
fix(insights): remove data caching & pregeneration, add revalidate
These features aren't scaling well as the number of price feeds grows: - The data cache doesn't seem to be reliably revalidating as expected, probably due to it being an experimental nextjs feature. Given the [new model for caching](https://nextjs.org/blog/composable-caching) that is coming in an upcoming nextjs release, I think it best to just remove the experimental caching until that lands. - The pregeneration is starting to take way too long as the number of price feeds grows drastically. Instead, this PR adds `revalidate` to routes that use API data for server-generation. This should avoid data cache issues while still serving pages from cache and regenerating them every hour. The initial page load will be slower since we aren't pregenerating any more, but subsequent page loads will be served from cache. If things still feel too slow, I'll investigate other solutions
1 parent ac83809 commit 517962f

File tree

14 files changed

+226
-337
lines changed

14 files changed

+226
-337
lines changed

apps/insights/src/app/layout.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
export { Root as default } from "../components/Root";
22
export { metadata, viewport } from "../metadata";
3+
4+
export const revalidate = 3600;
Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
11
import type { Metadata } from "next";
22

3-
import { Cluster, getFeeds } from "../../../services/pyth";
43
export { PriceFeedLayout as default } from "../../../components/PriceFeed/layout";
54

65
export const metadata: Metadata = {
76
title: "Price Feeds",
87
};
98

10-
export const generateStaticParams = async () => {
11-
const feeds = await getFeeds(Cluster.Pythnet);
12-
return feeds.map(({ symbol }) => ({ slug: encodeURIComponent(symbol) }));
13-
};
9+
export const revalidate = 3600;
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
11
export { ChartPage as default } from "../../../components/PriceFeed/chart-page";
2+
3+
export const revalidate = 3600;
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
11
export { Publishers as default } from "../../../../components/PriceFeed/publishers";
2+
3+
export const revalidate = 3600;

apps/insights/src/app/price-feeds/page.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,5 @@ export { PriceFeeds as default } from "../../components/PriceFeeds";
55
export const metadata: Metadata = {
66
title: "Price Feeds",
77
};
8+
9+
export const revalidate = 3600;
Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
11
import type { Metadata } from "next";
22

33
export { PublishersLayout as default } from "../../../components/Publisher/layout";
4-
import { getPublishers } from "../../../services/clickhouse";
54

65
export const metadata: Metadata = {
76
title: "Publishers",
87
};
98

10-
export const generateStaticParams = async () => {
11-
const publishers = await getPublishers();
12-
return publishers.map(({ key }) => ({ key }));
13-
};
9+
export const revalidate = 3600;
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
11
export { Performance as default } from "../../../components/Publisher/performance";
2+
3+
export const revalidate = 3600;
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
11
export { PriceFeeds as default } from "../../../../components/Publisher/price-feeds";
2+
3+
export const revalidate = 3600;

apps/insights/src/app/publishers/page.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,5 @@ export { Publishers as default } from "../../components/Publishers";
55
export const metadata: Metadata = {
66
title: "Publishers",
77
};
8+
9+
export const revalidate = 3600;

apps/insights/src/cache.ts

Lines changed: 0 additions & 16 deletions
This file was deleted.

0 commit comments

Comments
 (0)