perf: lazy-load ShaderGradient and fix image cache TTL

Co-authored-by: denshooter <44590296+denshooter@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot]
2026-03-01 22:12:27 +00:00
parent 96d7ae5747
commit 3ac7c7a5b3
3 changed files with 50 additions and 18 deletions

View File

@@ -3,7 +3,8 @@ import { getTechStack } from '@/lib/directus';
import { checkRateLimit, getClientIp } from '@/lib/auth';
export const runtime = 'nodejs';
export const dynamic = 'force-dynamic';
const CACHE_TTL = 300; // 5 minutes
/**
* GET /api/tech-stack
@@ -28,26 +29,24 @@ export async function GET(request: NextRequest) {
const techStack = await getTechStack(locale);
if (techStack && techStack.length > 0) {
return NextResponse.json({
techStack,
source: 'directus'
});
return NextResponse.json(
{ techStack, source: 'directus' },
{ headers: { 'Cache-Control': `public, s-maxage=${CACHE_TTL}, stale-while-revalidate=${CACHE_TTL * 2}` } }
);
}
// Fallback: return empty (component will use hardcoded fallback)
return NextResponse.json({
techStack: null,
source: 'fallback'
});
return NextResponse.json(
{ techStack: null, source: 'fallback' },
{ headers: { 'Cache-Control': `public, s-maxage=${CACHE_TTL}, stale-while-revalidate=${CACHE_TTL * 2}` } }
);
} catch (error) {
console.error('Error loading tech stack:', error);
if (process.env.NODE_ENV === 'development') {
console.error('Error loading tech stack:', error);
}
return NextResponse.json(
{
techStack: null,
error: 'Failed to load tech stack',
source: 'error'
},
{ techStack: null, error: 'Failed to load tech stack', source: 'error' },
{ status: 500 }
);
}