perf: lazy-load ShaderGradient and fix image cache TTL
Co-authored-by: denshooter <44590296+denshooter@users.noreply.github.com>
This commit is contained in:
@@ -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 }
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user