This PR implements Incremental Static Regeneration (ISR) for property detail pages to address issue #136. The implementation significantly improves performance by caching property pages while ensuring data freshness through automatic and on-demand revalidation.
- 60-second revalidation for property pages with ISR
- Background revalidation ensures fresh content
- CDN optimization with proper cache headers
- Reduced server load through intelligent caching
- Faster page loads for cached properties
- Converted property detail pages from client to server components
- Added
export const revalidate = 60for 60-second revalidation - Implemented async data fetching on server side
- PropertyDetailServer: Static content rendering (server component)
- PropertyDetailClient: Interactive elements (client component)
- Clean separation of server/client responsibilities
- Secure webhook endpoint:
/api/revalidate - HMAC-SHA256 signature verification for security
- Support for single property and bulk revalidation
- Comprehensive logging and error handling
- Custom 404 page for missing properties
- Helpful messaging for new properties
- Professional error handling with navigation options
- Optimized cache headers for property pages
stale-while-revalidatestrategy- Proper CDN caching configuration
src/app/properties/[id]/page.tsx- Converted to ISR server componentsrc/components/PropertyDetailServer.tsx- Server-side property contentsrc/components/PropertyDetailClient.tsx- Client-side interactive elementssrc/app/api/revalidate/route.ts- Webhook endpoint for revalidationsrc/app/properties/[id]/not-found.tsx- Custom 404 pagesrc/lib/propertyServiceServer.ts- Server-side data fetching utilitiesnext.config.ts- Added CDN cache headersISR_IMPLEMENTATION.md- Comprehensive documentation
- Webhook signature verification with HMAC-SHA256
- Environment variable for webhook secret
- Proper request validation and error handling
- Secure cache headers for authenticated routes
- Browser cache: 1 minute (
max-age=60) - Stale content: 5 minutes while revalidating (
stale-while-revalidate=300) - CDN cache: 5 minutes (
s-maxage=300)
The implementation includes:
- Comprehensive error handling
- Fallback pages for missing properties
- Webhook health check endpoint
- Proper TypeScript interfaces
Complete implementation documentation is available in ISR_IMPLEMENTATION.md including:
- Usage examples
- Security considerations
- Deployment instructions
- Troubleshooting guide
# Revalidate single property
curl -X POST https://your-domain.com/api/revalidate \
-H "Content-Type: application/json" \
-H "x-webhook-signature: <signature>" \
-d '{
"type": "property",
"propertyId": "property-123",
"reason": "Property updated"
}'This implementation follows Next.js best practices and includes proper error handling, security measures, and monitoring capabilities. The code is ready for testing and deployment.
Fixes #136