* fix: optimize PageSpeed Insights performance This commit addresses several PageSpeed Insights issues to improve the performance score from 56 to a target of 90+. Changes: - Add SWC config to output modern ES2022 JavaScript, eliminating unnecessary polyfills (~12 KiB savings) - Convert vocalinux.png to WebP format (17KB vs 207KB - 92% reduction) - Add OptimizedImage component with WebP/PNG fallback support - Add _headers file for proper static asset caching (1 year cache for immutable assets) - Configure Next.js with optimizePackageImports for framer-motion and lucide-react - Fix heading hierarchy issue (Quick Install h3 -> h2) - Add console.log removal in production builds Expected improvements: - Image delivery: ~41 KiB savings - Legacy JavaScript: ~12 KiB savings - Cache lifetime: 754 KiB proper caching - Accessibility score: 98 -> 100 (heading order fix) * test: add coverage for PageSpeed optimization Add comprehensive test suite for PageSpeed Insights optimization changes: - WebP image loading tests (optimized-image.tsx) - next/image component configuration tests (next.config.js) - _headers file generation and cache header tests - Lazy loading behavior tests Includes: - Jest configuration with TypeScript support - React Testing Library setup - 54 test cases covering all PageSpeed optimization features - Build verification All tests pass: npm run test Build passes: npm run build * ci: trigger workflow * ci: trigger workflow run * ci: trigger workflow
54 lines
1.1 KiB
Plaintext
54 lines
1.1 KiB
Plaintext
# Cache headers for static assets
|
|
# Improves PageSpeed Insights score by setting proper cache lifetimes
|
|
|
|
# Assets with long cache lifetime (1 year) - versioned by content hash
|
|
/_next/static/*
|
|
Cache-Control: public, max-age=31536000, immutable
|
|
|
|
# Font files - long cache (1 year)
|
|
/*.woff
|
|
/*.woff2
|
|
/*.ttf
|
|
/*.otf
|
|
Cache-Control: public, max-age=31536000, immutable
|
|
|
|
# Images - long cache (1 year)
|
|
/*.png
|
|
/*.jpg
|
|
/*.jpeg
|
|
/*.gif
|
|
/*.svg
|
|
/*.ico
|
|
/*.webp
|
|
/*.avif
|
|
Cache-Control: public, max-age=31536000, immutable
|
|
|
|
# Favicon and app icons
|
|
/apple-touch-icon.png
|
|
/favicon.ico
|
|
/android-chrome-*
|
|
Cache-Control: public, max-age=31536000, immutable
|
|
|
|
# HTML pages - short cache for revalidation
|
|
/*.html
|
|
Cache-Control: public, max-age=0, must-revalidate
|
|
|
|
# JSON and other data files
|
|
/*.json
|
|
Cache-Control: public, max-age=86400
|
|
|
|
# JavaScript chunks
|
|
/*.js
|
|
Cache-Control: public, max-age=31536000, immutable
|
|
|
|
# CSS files
|
|
/*.css
|
|
Cache-Control: public, max-age=31536000, immutable
|
|
|
|
# Security headers
|
|
/*
|
|
X-Content-Type-Options: nosniff
|
|
X-Frame-Options: DENY
|
|
X-XSS-Protection: 1; mode=block
|
|
Referrer-Policy: strict-origin-when-cross-origin
|