vinkius-labs/laravel-page-speed
Laravel Page Speed adds a configurable optimization pipeline to Laravel apps, improving latency and bandwidth for Blade pages and API responses. Enable only the middleware you need; works with common cache drivers and supports Laravel 10–13.
InlineCss or ApiResponseCache), reducing technical debt and enabling gradual rollouts.X-Response-Time, X-Cache-Status) integrate seamlessly with APM tools (Datadog, New Relic), making it ideal for data-driven optimization.bootstrap/app.php for v11+) ensures zero-breaking changes for existing projects.| Risk Area | Mitigation Strategy |
|---|---|
| Middleware Ordering | Explicit deterministic ordering in docs (e.g., InlineCss before DeferJavascript). |
| Cache Invalidation | Dynamic tag derivation per path segment reduces manual tag management. |
| Regex Overhead | Optimized PCRE usage (e.g., PCRE_DOTALL modifier) to avoid stack exhaustion. |
| Persistent Environments | State reset in middleware (e.g., InlineCss static properties) prevents leaks. |
| Debug Tool Conflicts | Skip patterns for Debugbar, Telescope, and Horizon routes. |
| Compression Overhead | Adaptive thresholds (Brotli/Gzip) avoid overhead on small payloads. |
Performance vs. Development Experience:
CollapseWhitespace) impact Livewire/Alpine.js debugging? (Mitigated by preserved attributes.)API Optimization Tradeoffs:
API_CACHE_TTL=300)?Cache::remember)?Observability:
X-Performance-Warning) needed in existing APM tools?Scaling:
Maintenance:
composer test) be added to CI/CD pipelines?web, api) and configuration files.LARAVEL_PAGE_SPEED_ENABLE=false in staging).ApiResponseCache + ApiResponseCompression (30% bandwidth savings).InlineCss + DeferJavascript (20% page weight reduction).CollapseWhitespace + ElideAttributes (fine-tuning).X-Cache-Status: HIT).| Component | Compatibility Notes |
|---|---|
| Laravel 10–13 | Full support; middleware registration varies by version. |
| PHP 8.2–8.4 | Optimized for modern PHP; no deprecated features used. |
| Redis/Memcached | Store-agnostic; dynamic tags reduce manual cache invalidation. |
| Livewire/Alpine.js | Preserved attributes (wire:, x-data) prevent JS corruption. |
| Tailwind/Bootstrap | Critical CSS inlining works with utility classes. |
| Debug Tools | Skip patterns for Debugbar, Telescope, Horizon. |
| CDNs | Cache headers (Cache-Control, ETag) compatible with Cloudflare, Fastly. |
\VinkiusLabs\LaravelPageSpeed\Middleware\ApiResponseCache::class
\VinkiusLabs\LaravelPageSpeed\Middleware\ApiResponseCompression::class
\VinkiusLabs\LaravelPageSpeed\Middleware\InlineCss::class
\VinkiusLabs\LaravelPageSpeed\Middleware\DeferJavascript::class
\VinkiusLabs\LaravelPageSpeed\Middleware\ApiCircuitBreaker::class
\VinkiusLabs\LaravelPageSpeed\Middleware\ApiHealthCheck::class
config/laravel-page-speed.php).4.x for Laravel 10–13) simplifies upgrades.X-Response-Time) aid troubleshooting.docs/API-OPTIMIZATION.md) with scenario playbooks.How can I help you explore Laravel packages today?