Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion bun.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 8 additions & 4 deletions web/src/app/api/agents/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import { unstable_cache } from 'next/cache'

import { logger } from '@/util/logger'

// Cache for 60 seconds with stale-while-revalidate
export const revalidate = 60
// Enable static generation for API route
export const revalidate = 600 // Cache for 10 minutes

// Cached function for expensive agent aggregations
const getCachedAgents = unstable_cache(
Expand Down Expand Up @@ -251,7 +251,7 @@ const getCachedAgents = unstable_cache(
},
['agents-data'],
{
revalidate: 60,
revalidate: 60 * 10, // Cache for 10 minutes
tags: ['agents'],
}
)
Expand All @@ -265,9 +265,13 @@ export async function GET() {
// Add cache headers for CDN and browser caching
response.headers.set(
'Cache-Control',
'public, max-age=60, s-maxage=60, stale-while-revalidate=300'
'public, max-age=600, s-maxage=600, stale-while-revalidate=600'
)

// Add additional headers for better CDN caching
response.headers.set('Vary', 'Accept-Encoding')
response.headers.set('X-Content-Type-Options', 'nosniff')

return response
} catch (error) {
logger.error({ error }, 'Error fetching agents')
Expand Down
16 changes: 6 additions & 10 deletions web/src/app/store/page.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import { Suspense } from 'react'
import { Metadata } from 'next'
import { getServerSession } from 'next-auth/next'
import { authOptions } from '@/app/api/auth/[...nextauth]/auth-options'
import { unstable_cache } from 'next/cache'
import AgentStoreClient from './store-client'

Expand Down Expand Up @@ -84,29 +82,27 @@ export const metadata: Metadata = {
},
}

// Enable static generation with revalidation
export const revalidate = 60
// Enable static site generation with ISR
export const revalidate = 60 * 10 // Revalidate every hour

interface StorePageProps {
searchParams: { [key: string]: string | string[] | undefined }
}

export default async function StorePage({ searchParams }: StorePageProps) {
// Get session for conditional rendering
const session = await getServerSession(authOptions)

// Fetch agents data at build time / on revalidation
// Fetch agents data at build time
const agentsData = await getCachedAgentsData()

// For now, pass empty array for publishers - client will handle this
// For static generation, we don't pass session data
// The client will handle authentication state
const userPublishers: PublisherProfileResponse[] = []

return (
<Suspense fallback={<StorePageSkeleton />}>
<AgentStoreClient
initialAgents={agentsData}
initialPublishers={userPublishers}
session={session}
session={null} // Client will handle session
searchParams={searchParams}
/>
</Suspense>
Expand Down
Loading