Library / SDK
vinkius-labs/laravel-page-speed avatar
vinkius-labs/laravel-page-speed

The Laravel Page Speed numbers are cache hits, and middleware order is the contract

Package to optimize your site automatically which results in a 35%+ optimization. Laravel Page Speed delivers an end-to-end optimization pipeline for Blade-rendered pages and REST APIs with measurable gains in latency, bandwidth, and resiliency.

2,508 stars290 forksPHPMIT

At a glance

What is it?
A composable set of Laravel middleware for HTML and API responses, sold on a measured-impact table whose entire after column is conditioned on a cache hit, and integrated by appending classes in a fixed order.
Who is it for?
This package fits a Laravel application on version 10 through 13 that renders Blade or JSON and has a cache store it trusts, because every mechanism it offers is a middleware class you append in a stated order and a config file you can turn on selectively. It does not fit a team reading the impact table as a promise: those numbers are one scenario with a 65 percent cache hit rate at a million requests a day, and the SQL row only applies to the cached list path.
Can I use it commercially?
Yes. MIT is a permissive licence: you can use, modify and sell software built on it, as long as you keep its copyright and licence notices.
Is it still maintained?
Yes. The repository last received commits 164 days ago.
What is it written in?
Mainly PHP, according to GitHub's language statistics.

Answers come from the project's GitHub data, last synced on November 15, 2026, and from our analysis. They are not legal advice.

From daily snapshots

Star history

  • vinkius-labs/laravel-page-speed2,508 ★ · -1
Star history
Repository2026-09-292026-11-15
vinkius-labs/laravel-page-speed2.5k2.5k

-1 Stars in the last 47 days, measured from the daily GitHub snapshot. Compare with other projects

Editorial analysis

The badge row carries two vendor names for one package

Six badges sit at the top of the README and they are not all the same link. Five point at packagist.org/packages/vinkius-labs/laravel-page-speed, and one points at packagist.org/packages/renatomarinho/laravel-page-speed. The project has been published under two vendors, and the README carries both, which is the kind of detail that decides whether a search for the package finds it.

The install instructions only use the newer name:

bash
composer require vinkius-labs/laravel-page-speed
php artisan vendor:publish --provider="VinkiusLabs\\LaravelPageSpeed\\ServiceProvider"

Publishing the assets matters because the package is configured through config/laravel-page-speed.php, and the overview says the stack is composable because you enable only the middleware you need through that file. So the vendor:publish step is not optional for anyone who intends to change a default, and the namespace inside the code is VinkiusLabs\LaravelPageSpeed regardless of which vendor name the package was fetched under.

There is also a community pitch before the title, an invitation to a Discord where the maintainer says they are present, framed around performance wins and edge cases. It is the first thing in the file and it is the only part of the README addressed to a person rather than to a configuration file.

Every figure in the impact table sits on the same cache hit

The measured impact table is the reason most people read this README, so its shape matters. There are three numeric columns: Before, After (cache hit), and Delta. The middle column is not an average. It is the state of the system when the cache answers, and the reference scenario under the table says one million requests a day with a 65 percent cache hit rate.

The rows are Blade page size from 245 KB to 159 KB, first paint from 1.8 s to 1.2 s, API payload from 15.2 KB to 2.8 KB, average API latency from 450 ms to 2 ms, SQL queries on a 100-item list from 35 to 0, and an estimated monthly bandwidth from 15 TB to 3 TB. Two of those deserve reading closely. The SQL row reaching zero is a property of a cached list rather than of a faster query, and the bandwidth row is labelled an estimate in the table itself.

The project description carries the headline claim of a 35 percent or greater optimization, which matches the Blade page size row and the first paint row rather than standing on its own. None of these numbers describe a miss, and the README does not give a miss column, so the cost of the cache being cold is not part of the table.

Two registration paths, and two of the four snippets stop mid-line

Middleware has to be registered, and the shape of that registration changed in Laravel 11. For Laravel 10.x the file is app/Http/Kernel.php and the middleware is appended inside the web group so the order stays deterministic:

php
protected $middlewareGroups = [
    'web' => [
        // ... existing middleware
        \VinkiusLabs\LaravelPageSpeed\Middleware\InlineCss::class,
        \VinkiusLabs\LaravelPageSpeed\Middleware\ElideAttributes::class,
        \VinkiusLabs\LaravelPageSpeed\Middleware\InsertDNSPrefetch::class,
        \VinkiusLabs\LaravelPageSpeed\Middleware\CollapseWhitespace::class,
        \VinkiusLabs\LaravelPageSpeed\Middleware\DeferJavascript::class,
    ],
];

Five classes in a fixed sequence, and the ordering is the point: inline CSS first, then attribute elision, then DNS prefetch, then whitespace collapsing, then deferred JavaScript. For Laravel 11.x, 12.x and 13.x the same five are appended through the ->withMiddleware closure in bootstrap/app.php using appendToGroup.

Two of the four snippets are cut off where they are printed. The Laravel 11 web example ends mid-line inside the namespace of the fifth class, and the Laravel 10 API example ends partway through the class name ApiHealthCheck. The Laravel 11 API example is the complete one, listing seven classes from ApiSecurityHeaders through ApiHealthCheck. So the API stack can be read in full from one path and not from the other, which is a small trap for anyone copying the older file layout.

data-ps-* guards are how deferral survives execution order

The web pipeline has three parts and each one is constrained rather than simple. HTML minification and comment stripping are structured, and the stated goal is compatibility with Bootstrap, Tailwind and Livewire, which is the constraint that rules out the aggressive kind of minification. Critical CSS inlining is targeted, meaning it moves the blocking stylesheet rather than inlining everything.

Script deferral and DNS prefetching are where the mechanism gets specific: execution order is maintained through data-ps-* guards. That is the project's own attribute namespace appearing in the output HTML, so the deferral is not a blind rewrite of script tags but something that marks them and keeps the order the page declared. A reader of the generated markup will see those attributes on their own elements, which is also the first place to look when a page misbehaves after installing the package.

The split between the web and API pipelines is the other structural fact. Web middleware works on rendered HTML, API middleware works on JSON and XML payloads, and the overview states that neither modifies your business payloads, which is the promise that the transforms are confined to the response envelope rather than to what your controllers return.

Compression has a size threshold, and cache tags are derived per path segment

The API pipeline is where the configuration matters most. Compression is adaptive rather than always on: Brotli is tried first, Gzip is the fallback, and there are configurable size thresholds so a small payload is not made larger by being compressed. That threshold is the difference between a compression middleware that helps and one that costs CPU on every tiny response.

Response caching is described in three parts. Invalidation is method aware, so a write invalidates rather than serving a stale read. Tags are derived dynamically per path segment, which is what makes a list and its items separate cache entries rather than one blob. And hit-rate metrics are recorded, which is the number you need before trusting any of the impact figures.

Store support is the widest part of the claim: Redis, Memcached, DynamoDB through cache tags, file and array drivers, across Laravel 10 through 13. The DynamoDB route is the interesting one, because it is qualified by going through cache tags, so it depends on tag support rather than being a plain key-value store. The package declares itself store-agnostic, and the mechanism it actually needs from a store is tags.

Five environment variables are the whole recommended baseline

The baseline configuration for a cached API is five lines, and they are worth reading as a description of the intended deployment rather than as a starting snippet:

env
LARAVEL_PAGE_SPEED_ENABLE=true
API_CACHE_ENABLED=true
API_CACHE_DRIVER=redis
API_CACHE_TTL=300
API_CACHE_DYNAMIC_TAGS=true

The first is the master switch, the second turns response caching on separately, and the third picks Redis rather than leaving the driver to the application default. The TTL is 300, five minutes, which is a short window that suits content that changes and leaves the invalidation story doing less work. The last line enables the per-path-segment tag derivation, and it is the one that interacts with the store: dynamic tags need a driver that can address entries by tag, so turning this on with a file or array driver changes what the cache layer is asked to do.

Nothing here is framework specific beyond the variable names, which is what lets the same package sit on Laravel 10 through 13. What is framework specific is where the classes are appended, which is the difference covered by the two registration paths.

Four response headers, and a circuit breaker with three scopes

Observability is delivered as standard HTTP headers rather than as a metrics library, and the four names are fixed: X-Response-Time, X-Memory-Usage, X-Cache-Status and X-Circuit-Breaker-State. The README names Datadog, New Relic and Prometheus scrapers as the intended consumers, which tells you these are meant to be scraped or collected as they are rather than exported through an agent.

The circuit breaker is configurable in three dimensions: failure thresholds, timeout, and scope, where scope is a route, an endpoint or a path. Route-level is the coarse choice and path-level the fine one, and the API pipeline pairs the breaker with pre-hardened security headers, HSTS, CSP and Permissions-Policy.

The health check aggregates database, cache, disk and queue probes, and can cache its own result for ten seconds so a Kubernetes probe hitting every few seconds does not run four checks every time. The last item in that section is debug-aware skipping, where curated skip patterns avoid instrumenting, and the sentence describing what they avoid is cut off after avoid instr. So the mechanism is named and the list of what it excludes is not shown.

The Docker image installs without a lock file, and the compose service idles

There is a Dockerfile, a docker-compose.yml and a DOCKER.md at the root, and the image is built for development rather than for running the package. It starts FROM php:8.2-cli, installs git, curl, zip and unzip, copies the composer binary from the composer:latest image, and runs composer install with --no-interaction --no-scripts --no-autoloader --prefer-dist before copying the application and generating an optimized autoloader. One comment in the file is in Portuguese, noting that the PHP 8.2 CLI image already carries the extensions needed.

The dependency copy is COPY composer.json composer.lock* ./, with the lock file optional. That glob is the whole reproducibility story: if no lock file is present the install resolves versions at build time, and the resulting image is not pinned to anything.

The compose file then does something worth noticing. The app service builds from that Dockerfile, mounts . and ./vendor into /var/www/html, and its command is tail -f /dev/null, so the container starts and does nothing. Nothing serves the application; you are expected to run commands inside it. The final image command is php -a, the PHP built-in server, rather than an artisan entry point.

Alongside .github/ the root still carries a .travis.yml, so continuous integration configuration exists in two generations, and phpunit.xml.dist sits beside tests/ for the package's own suite.

Editorial conclusion

This package fits a Laravel application on version 10 through 13 that renders Blade or JSON and has a cache store it trusts, because every mechanism it offers is a middleware class you append in a stated order and a config file you can turn on selectively. It does not fit a team reading the impact table as a promise: those numbers are one scenario with a 65 percent cache hit rate at a million requests a day, and the SQL row only applies to the cached list path. Three things to check first: which middleware order your install actually has, since the Laravel 10 and Laravel 11 registration paths differ and the order is not alphabetical by intent; whether the cache store you intend to use supports the tag-based invalidation the API stack relies on; and whether your API responses are safe to serve from cache, because method-aware invalidation and dynamic tag derivation are only as good as the paths you tag. Treat the release notes as the real changelog, since v4.4.4 describes itself as code hygiene and regex simplification rather than a behaviour change.

Frequently asked questions

How do I install vinkius-labs/laravel-page-speed?

Run composer require vinkius-labs/laravel-page-speed, then publish the assets with php artisan vendor:publish for the VinkiusLabs\LaravelPageSpeed\ServiceProvider. Publishing matters because the middleware stack is enabled through config/laravel-page-speed.php rather than by code. The package is also published under the renatomarinho vendor name, which one of the README badges still links to.

What does the measured impact table in laravel-page-speed actually measure?

Its middle column is headed After (cache hit), and the reference scenario beneath it is one million requests a day with a 65 percent cache hit rate. The rows are Blade page size, first paint, API payload, average API latency, SQL queries on a 100-item list and estimated monthly bandwidth, so the zero SQL row describes a cached list rather than a faster query.

Does laravel-page-speed support every Laravel version?

It states support across Laravel 10 through 13, with a store-agnostic cache layer working with Redis, Memcached, DynamoDB through cache tags, file and array drivers. Registration differs by version: Laravel 10 appends the classes in app/Http/Kernel.php, while Laravel 11, 12 and 13 append them in the ->withMiddleware closure in bootstrap/app.php.

Which HTTP headers does laravel-page-speed emit?

Four: X-Response-Time, X-Memory-Usage, X-Cache-Status and X-Circuit-Breaker-State, which the README says are ready for ingestion by Datadog, New Relic or Prometheus scrapers. The circuit breaker behind the last header is configurable in failure thresholds, timeout and scope, where scope can be a route, an endpoint or a path.

Official sources

  1. Issues
  2. License: MIT
  3. README
  4. Releases
  5. vinkius-labs/laravel-page-speed on GitHub
Add this badge to your README

If you maintain this project, the badge below links readers to this analysis and shows its maintenance status from the daily GitHub snapshot. Paste the markdown into your README; add ?metric=license or ?metric=stars to the image URL for a different field.

Add this badge to your README

markdown
[![Hysen Labs](https://hysenlabs.com/badge/vinkius-labs-laravel-page-speed.svg)](https://hysenlabs.com/projects/vinkius-labs-laravel-page-speed)

Star history chart for your README

markdown
[![Star history](https://hysenlabs.com/chart/vinkius-labs-laravel-page-speed.svg)](https://hysenlabs.com/projects/vinkius-labs-laravel-page-speed)

Was this useful?