vinkius-labs/laravel-page-speed
Laravel Page Speed is an end-to-end optimization pipeline for Blade-rendered pages and REST APIs, with composable middleware, measurable latency and bandwidth gains, store-agnostic caching, and built-in observability and resilience for Laravel 10–13.
Architecture fit. The package is a middleware-based response-transformation layer that sits at the edge of the Laravel HTTP lifecycle, between controller output and the client. It does not touch routing, models, or business logic, which is the lowest-blast-radius integration pattern available in Laravel. The composable middleware model (enable only what you need via config/laravel-page-speed.php) is the right design for a TPM: it makes adoption incremental and reversible per optimization rather than a single all-or-nothing switch. Dual scope (Blade HTML + JSON/XML APIs) means one dependency can serve both the web and API squads, which reduces procurement and review overhead but also concentrates risk in a single package.
Integration feasibility. Very high. composer require plus middleware registration in app/Http/Kernel.php (Laravel 10) or bootstrap/app.php (Laravel 11–13), then vendor:publish for config. Both registration patterns are documented explicitly, and the version matrix (Laravel 10–13, PHP ^8.2) covers current and next-cycle stacks. Realistic effort is 1–2 engineer-days for a working spike and 1–2 sprints for a production rollout including QA. The presence of docs, changelog, releases, and a Discord channel suggests the support surface exists even if informal.
Technical risk. The dominant risk class is regex-based HTML rewriting, and the changelog is effectively a catalogue of that risk materializing: PCRE stack exhaustion producing blank pages (fixed 4.4.2), Livewire/Alpine attributes corrupted during whitespace collapsing (fixed 4.4.2), TrimUrls corrupting JS strings, meta tags, and SVG namespaces (fixed 4.4.3), and state leaks across requests under Octane/Swoole (fixed 4.4.1). Each has been remediated, and the maintainers added a Content-Type guard that prevents web middleware from touching JSON/XML — a genuinely important safety fix. But the pattern tells us this package has been hardened by production incidents, not by design review, and we should assume more edge cases exist. Secondary risks: middleware that emits security headers (HSTS, CSP, Permissions-Policy) creates an ownership ambiguity with the app, the CDN, and the WAF — misconfiguration here breaks third-party scripts in ways that are hard to attribute. Tertiary: response caching introduces invalidation-correctness risk, and the circuit breaker introduces a new failure mode of its own (false tripping).
Key questions.
renatomarinho/laravel-page-speed. This strongly implies vinkius-labs is a fork or successor of a well-known package. We need to confirm: is the star count inherited, transferred, or organic? Who is the legal maintainer of record? Is there a documented migration path from upstream, and does the upstream receive security fixes this fork inherits?ApiSecurityHeaders, does the package own CSP/HSTS, or does our edge? A silent X-XSS-Protection: 0 change (4.4.3) is a good default but a decision we should own explicitly.ApiResponseCache intended for authenticated endpoints? The method-aware invalidation and dynamic tag derivation need a documented guarantee that user-scoped responses cannot collide. This is the single highest-severity unknown.Stack fit. Strong for a standard Laravel 10–13 monolith or modular monolith. Works with Redis, Memcached, DynamoDB, file, and array cache drivers — but our production driver should drive the scope of what we enable. If we run Redis with cluster mode, validate tag derivation behavior under key hashing before committing to the caching middleware. If we already terminate TLS at a CDN or ALB that does Brotli/Gzip and HTTP caching, the compression and cache middleware duplicate edge capability and add CPU cost inside PHP for marginal benefit; in that topology we should consider adopting only the low-risk web minification plus observability headers. The circuit breaker and health check middleware overlap with Kubernetes probes, service mesh retries, and existing APM — adopt only if we have a gap.
Migration path. Do not do a big-bang adoption. Sequence a shadow pilot first: install on a throwaway Laravel 11 and Laravel 12 app, exercise the web pipeline against realistic Blade templates (Bootstrap, Tailwind, Livewire, Alpine, inline <script type="application/ld+json">) and the API pipeline against representative JSON, XML, streaming, and file-download responses. Then pilot in production behind LARAVEL_PAGE_SPEED_ENABLE, starting with the middleware that changes nothing semantically.
Compatibility and ordering. Middleware order is the deliverable, not an afterthought. For the API group, compression must wrap (not be wrapped by) cache so cached payloads are already encoded or encoded per-negotiation; ApiETag must respect pre-existing Cache-Control (the 4.4.3 fix does this, but our own middleware may still conflict); ApiPerformanceHeaders must run outermost to measure the full stack. For the web group, CollapseWhitespace and RemoveComments must run after anything that injects markup and before DeferJavascript. Confirm the app's existing middleware — Debugbar, Telescope, Horizon are skipped by default, which is good, but any custom diagnostics or HTML-rewriting middleware must be reconciled. Verify Octane/Swoole compatibility explicitly given the 4.4.1 state-leak history.
Sequencing.
ApiPerformanceHeaders and ApiHealthCheck in staging. Zero semantic change, immediate instrumentation, validates the header contract with our APM ingestion.CollapseWhitespace, RemoveComments, ElideAttributes behind a flag on a low-traffic marketing surface. Visual regression suite plus a Livewire/Alpine interaction smoke test are mandatory gates, not optional.ApiResponseCompression, ApiETag, ApiSecurityHeaders on unauthenticated read-only endpoints. Measure CPU headroom — Brotli is materially more expensive than Gzip at scale.ApiResponseCache and ApiCircuitBreaker last, only on idempotent GETs with an explicit tag and invalidation strategy written down, and only after a load test that includes deploy-time invalidation.Maintenance. MIT license, small maintainer team, fast release cadence, and a detailed changelog — the latter is the most operationally valuable artifact here because it tells us exactly what kinds of defects to test for on upgrade. The cost is churn: 4.4.1 through 4.4.4 all contain correctness fixes, not just cosmetic ones. Pin exact versions in composer.json, review every diff, and never auto-merge. Budget roughly 1 engineer-day per release cycle to read the changelog, run the regression suite, and decide on adoption.
Support. Community-only — GitHub Issues, Discussions, Discord. No SLA, no indemnification, no security disclosure policy we can point to. Mitigation: record it in the vendor risk register, nominate an internal owner, and confirm that a fork is viable (it is: MIT, middleware-only, no native extensions). If this becomes load-bearing for revenue paths, we should have an internal branch ready to go within a sprint.
Scaling. Three cost surfaces. (1) CPU per request for HTML minification on dynamic pages — this scales linearly with traffic and does not benefit from caching; cap it by only enabling the rewrite middlewares where the rendered output is itself cached or where egress is the binding constraint. (2) CPU and memory for Brotli — measure under sustained load, not a single request. (3) The cache backend becomes a hard dependency with its own capacity, eviction, and hot-key profile; tag cardinality can explode if dynamic tag derivation produces per-request tags, and cache-tag explosion is a common production failure. Size Redis and set eviction policy before enabling, not after.
Failure modes to instrument and rehearse.
Ramp-up. Low to moderate. Any Laravel engineer can wire this up in an afternoon; the real learning curve is in the areas the package assumes you already understand: HTTP caching semantics (ETag, Vary, Cache-Control), middleware ordering, and CSP. Allocate one engineer as owner, two engineer-days of training on the config reference and cache architecture docs, and a written runbook covering rollback (flip LARAVEL_PAGE_SPEED_ENABLE), cache flush, and per-middleware disable. Expect meaningful value in the first month from compression and observability alone; treat the caching layer as a second, separately justified phase. The 0-dependents signal means we are among the earliest production adopters at scale — price that into the pilot duration rather than assuming ecosystem battle-testing we do not have.
How can I help you explore Laravel packages today?