Next-Level Performance: Mastering Laravel 12.34 and 12.35 New Features

Overview

just released versions 12.34 and 12.35, introducing powerful tools to manage asynchronous tasks and system resilience. These updates focus on improving the user experience by moving heavy workloads out of the request-response cycle and providing robust failover mechanisms for mission-critical services like
Redis
.

Prerequisites

To follow along, you should have a solid grasp of:

  • PHP 8.2 or higher
  • Basic understanding of the Laravel Service Container and
    Queues
  • Familiarity with config/cache.php and config/queue.php structures

Key Libraries & Tools

  • Laravel Framework: The core PHP framework receiving these updates.
  • Redis: Often used as the primary driver for both caching and queuing.
  • Laravel Herd: A local development environment used to demonstrate service management.

The Deferred Queue Connection

One of the most impactful additions is the deferred queue connection. Unlike the standard sync driver—which blocks the user's browser until the job finishes—the deferred driver processes the job immediately after the HTTP response is sent to the client.

// In your Controller
ProcessNewPost::dispatch($post)->onConnection('deferred');

return redirect()->route('posts.index');

By switching to the deferred connection, the user sees an immediate redirect, while the "heavy" logic runs in the background. This provides the speed of an asynchronous worker without needing to configure a separate daemon for local development.

Implementing Failover Strategies

Systems fail.

now provides a native failover driver for both
Caching
and
Queues
. If your primary
Redis
instance goes down, the system automatically falls back to your secondary store.

// config/cache.php
'stores' => [
    'failover' => [
        'driver' => 'failover',
        'stores' => ['redis', 'database', 'array'],
    ],
]

Syntax Notes

  • Fluent Configuration: The failover driver expects a prioritized list of stores in the stores array.
  • Driver Switching: You must update your .env file (e.g., CACHE_STORE=failover) to activate these strategies.

Tips & Gotchas

  • Persistence: Remember that the array cache driver is not persistent across requests; use database as a secondary fallback if data persistence is required during
    Redis
    outages.
  • Debugging: When using the deferred connection, use Log::info() to verify job completion since you won't see errors in the browser once the response is sent.
2 min read