# Performance Optimization Plan

## Target Metrics

| Metric | Target |
|--------|--------|
| Lighthouse Performance | 95-100 |
| Lighthouse SEO | 100 |
| Lighthouse Accessibility | 100 |
| Lighthouse Best Practices | 100 |
| LCP | < 2.5s |
| FID/INP | < 200ms |
| CLS | < 0.1 |

## Implemented Optimizations

### Backend
- Redis cache for homepage stats, featured/latest jobs
- Eager loading on all list queries (`with(['company', 'category'])`)
- Database indexes on status, published_at, category, district, fulltext search
- Queue-based email notifications
- Route, config, view caching (production)
- Scout-ready job indexing

### Frontend
- Tailwind CSS purged via Vite
- Alpine.js in separate chunk
- Lazy loading images (`loading="lazy"`)
- Preconnect to Google Fonts
- Minimal JS bundle (Alpine only on public pages)
- AJAX job filtering (no full page reload)

### SEO
- Dynamic meta tags per page
- JSON-LD structured data (JobPosting, Organization, WebSite, BreadcrumbList)
- Auto-generated XML sitemap
- Canonical URLs
- Semantic HTML with ARIA labels
- robots.txt blocking admin/dashboard routes

## Production Checklist

```bash
php artisan config:cache
php artisan route:cache
php artisan view:cache
php artisan event:cache
npm run build
```

### Server
- Enable OPcache (128MB+, validate_timestamps=0 in production)
- Redis for cache, sessions, queues
- Nginx gzip/brotli compression
- CDN for `/build/` assets and images
- Cloudflare proxy with caching rules

### Images
- Store logos/covers as WebP (Intervention Image ready)
- Responsive `width`/`height` attributes to prevent CLS
- Alt tags on all images

### Database
- Monitor slow queries (>100ms)
- Use `EXPLAIN` on job search queries
- Consider read replicas at scale

## Monitoring

- Google PageSpeed Insights (weekly)
- Google Search Console (index coverage)
- Laravel Telescope (staging)
- Redis memory usage alerts
