vinkius-labs/laravel-page-speed
Optimize Laravel HTML and API responses with a configurable middleware pipeline: minify HTML/JSON/XML, add cache headers, ETags, compression and more. Works across Laravel 10โ13 with any cache store (Redis, Memcached, file, etc.) for faster, leaner responses.
API_CACHE_DRIVER instead of the default cache driver, ensuring consistent state sharing in distributed environments.X-Performance-Warning header being silently overwritten when both high query count and slow request conditions triggered simultaneously. Both warnings are now combined.ok status without actually probing the queue driver. Now calls Queue::connection()->size() to verify connectivity.Cache-Control header overwrite that could conflict with application-level or other middleware caching directives. Now respects existing headers.new Response() instantiation in shouldCache() โ uses isEnable() directly.Content-Type guard in the base handle() method โ web middleware now skips non-HTML responses (application/json, application/xml, etc.), preventing silent data corruption on misconfigured middleware groups.https:, http:) is now limited to src, href, and action attributes only, preventing corruption of JavaScript strings, meta tags, and SVG namespaces.X-XSS-Protection from deprecated 1; mode=block to 0 as recommended by MDN, relying on CSP for XSS protection instead.^8.2 || ^8.3 to ^8.2, which correctly covers PHP 8.2, 8.3, 8.4, and future 8.x releases.replaceInsideHtmlTags by utilizing the s (PCRE_DOTALL) modifier to avoid nested groups, and added fallback to original content to prevent page breaks on regex failures.wire:snapshot, wire:effects, x-data, x-init) were corrupted during minification by explicitly preserving them.restorePreservedContent by replacing foreach + str_replace loop with native strtr(), significantly improving performance on large HTML payloads.logPerformanceMetrics() call that passed pre-computed elapsed time instead of raw start time, resulting in wildly inaccurate debug metrics (~1.7 billion ms). The parent PageSpeed::handle() already provides correct, debug-only performance logging.$class, $style, and $inline are now reset at the beginning of each apply() call.$isEnabled cache that was never cleared, causing runtime configuration changes to be silently ignored in persistent environments.supportsTags() method and corrected invalidateCache() return type from [@return](https://github.com/return) void to [@return](https://github.com/return) bool.*.doc entry in the skip list.ConfigTest to validate correct behavior: isEnable() now reflects runtime configuration changes instead of returning a stale cached value.^12.5.12)illuminate/support constraint to ^10.0 || ^11.0 || ^12.0 || ^13.0phpunit/phpunit constraint to ^10.5 || ^11.0 || ^12.5.12orchestra/testbench constraint to ^8.0 || ^9.0 || ^10.0 || ^11.0/class="(.*?)"/ to /(?<![-:])class="(.*?)"/i using negative lookbehindng-class (AngularJS), :class (Alpine.js), v-bind:class (Vue.js)ng-class work correctly (Issue #75):class shorthand works correctly (Issue #154)v-bind:class works correctlyInlineCssJavaScriptFrameworksTest with 7 comprehensive tests (42 assertions)ng-class compatibility:class shorthand compatibilityv-bind:class compatibility[@test](https://github.com/test) annotation to test_* method naming convention$defer property from ServiceProvider$defer property from ServiceProviderRequirements:
Steps:
composer.json:{
"require": {
"php": "^8.2 || ^8.3",
"laravel/framework": "^10.0 || ^11.0 || ^12.0",
"vinkius-labs/laravel-page-speed": "^3.0"
}
}
composer update vinkius-labs/laravel-page-speed
php artisan config:clear
php artisan cache:clear
Breaking Changes:
ServiceProvider class, remove the $defer propertyStaying on v2.x:
If you need to stay on Laravel 6-9 or PHP 8.0/8.1, use version constraint:
{
"require": {
"vinkius-labs/laravel-page-speed": "^2.1"
}
}
See previous releases for v2.x changelog.
How can I help you explore Laravel packages today?