diff --git a/src/app/(dashboard)/dashboard/cache/page.tsx b/src/app/(dashboard)/dashboard/cache/page.tsx index 24064e8403..0f514543cb 100644 --- a/src/app/(dashboard)/dashboard/cache/page.tsx +++ b/src/app/(dashboard)/dashboard/cache/page.tsx @@ -5,6 +5,7 @@ import { Card, Button, EmptyState } from "@/shared/components"; import { useNotificationStore } from "@/store/notificationStore"; import { useTranslations } from "next-intl"; import CacheEntriesTab from "./components/CacheEntriesTab"; +import CacheStatsCard from "../settings/components/CacheStatsCard"; // ─── Types ─────────────────────────────────────────────────────────────────── @@ -371,7 +372,9 @@ export default function CachePage() {
{promptCacheHitRate.toFixed(1)}%
-
{t("cacheHitRate")}
+
+ {t("cacheHitRate")} ({pc.requestsWithCacheControl}/{pc.totalRequests}) +
@@ -432,6 +435,9 @@ export default function CachePage() { )} + {/* Prompt Cache Metrics (cumulative with reset) */} + + {/* Cache Trend (24h) */} {trend.length > 0 && ( diff --git a/src/app/(dashboard)/dashboard/settings/components/CacheStatsCard.tsx b/src/app/(dashboard)/dashboard/settings/components/CacheStatsCard.tsx index d269907683..7876a67fdf 100644 --- a/src/app/(dashboard)/dashboard/settings/components/CacheStatsCard.tsx +++ b/src/app/(dashboard)/dashboard/settings/components/CacheStatsCard.tsx @@ -63,132 +63,141 @@ export default function CacheStatsCard() { : 0; return ( - -
-

- insights - Prompt Cache Metrics -

- -
- - {metrics ? ( -
- {/* Overview Stats */} -
-
-

Total Requests

-

{metrics.totalRequests}

-
-
-

With Cache Control

-

{metrics.requestsWithCacheControl}

-
+ +
+
+
+ +

Prompt Cache Metrics

- - {/* Token Stats */} -
-
-

Input Tokens

-

- {metrics.totalInputTokens.toLocaleString()} -

-
-
-

Cached Tokens (Read)

-

- {metrics.totalCachedTokens.toLocaleString()} -

-
-
-

Cache Creation (Write)

-

- {metrics.totalCacheCreationTokens.toLocaleString()} -

-
-
- - {/* Cache Ratio */} -
-
-
-

Cache Reuse Ratio

-

Cached tokens / Total input tokens

-
-

{cacheHitRate.toFixed(1)}%

-
- {/* Progress bar */} -
-
-
-
- - {/* Savings */} -
-
-

Tokens Saved

-

- {metrics.tokensSaved.toLocaleString()} -

-
-
-

Est. Cost Saved

-

- ${metrics.estimatedCostSaved.toFixed(4)} -

-
-
- - {/* By Provider */} - {Object.keys(metrics.byProvider).length > 0 && ( -
-

By Provider

-
- {Object.entries(metrics.byProvider).map(([provider, stats]) => { - const providerCacheRate = - stats.inputTokens > 0 ? (stats.cachedTokens / stats.inputTokens) * 100 : 0; - return ( -
-
- {provider} - {stats.requests} reqs -
-
- - In: {stats.inputTokens.toLocaleString()} - - - Cached: {stats.cachedTokens.toLocaleString()} - - - Write: {stats.cacheCreationTokens.toLocaleString()} - - - {providerCacheRate.toFixed(0)}% - -
-
- ); - })} -
-
- )} +
- ) : ( -

Loading cache metrics...

- )} + + {metrics ? ( +
+ {/* Overview Stats */} +
+
+

Total Requests

+

{metrics.totalRequests}

+
+
+

With Cache Control

+

+ {metrics.requestsWithCacheControl} +

+
+
+ + {/* Token Stats */} +
+
+

Input Tokens

+

+ {metrics.totalInputTokens.toLocaleString()} +

+
+
+

Cached Tokens (Read)

+

+ {metrics.totalCachedTokens.toLocaleString()} +

+
+
+

Cache Creation (Write)

+

+ {metrics.totalCacheCreationTokens.toLocaleString()} +

+
+
+ + {/* Cache Ratio */} +
+
+
+

Cache Reuse Ratio

+

Cached tokens / Total input tokens

+
+

{cacheHitRate.toFixed(1)}%

+
+ {/* Progress bar */} +
+
+
+
+ + {/* Savings */} +
+
+

Tokens Saved

+

+ {metrics.tokensSaved.toLocaleString()} +

+
+
+

Est. Cost Saved

+

+ ${metrics.estimatedCostSaved.toFixed(4)} +

+
+
+ + {/* By Provider */} + {Object.keys(metrics.byProvider).length > 0 && ( +
+

By Provider

+
+ {Object.entries(metrics.byProvider).map(([provider, stats]) => { + const providerCacheRate = + stats.inputTokens > 0 ? (stats.cachedTokens / stats.inputTokens) * 100 : 0; + return ( +
+
+ {provider} + {stats.requests} reqs +
+
+ + In: {stats.inputTokens.toLocaleString()} + + + Cached: {stats.cachedTokens.toLocaleString()} + + + Write: {stats.cacheCreationTokens.toLocaleString()} + + + {providerCacheRate.toFixed(0)}% + +
+
+ ); + })} +
+
+ )} +
+ ) : ( +

Loading cache metrics...

+ )} +
); }