Laravel Livewire vs Inertia.js Performance Guide

Avatar
M

Maksudur Rahman

Software Engineer•
1Views
5mRead
0Reactions

You need a Laravel SPA that feels snappy, but you’re stuck choosing between Livewire and Inertia.js. Both promise a full‑stack experience, yet their runtime footprints differ. This guide measures laravel livewire vs inertia.js performance so you can pick with data, not guesswork.

TL;DR / Quick Summary

Run the Octane‑backed benchmark suite, compare ApacheBench latency and Lighthouse TTI, then apply the caching tweaks shown. Livewire stays under 120 ms for simple CRUD, Inertia hits ~90 ms but adds a 45 KB JS bundle. Choose Livewire for tiny bundles, Inertia for raw speed.

Benchmark Setup

Environment

  • Laravel 11, PHP 8.3, Octane (Swoole) running on a 4‑core VM.

  • ApacheBench (ab -n 500 -c 50) for raw request latency.

  • Chrome Lighthouse (mobile, no‑cache) for Time‑to‑Interactive.

  • Vite‑powered Vue 3 for Inertia, Livewire assets compiled with Laravel Mix.

Tip: The Octane article "Laravel Octane vs FPM Performance: Real‑World Trade‑offs" explains why we lock the server to Swoole for a fair comparison.

Livewire Benchmark

Create a simple CRUD page at app/Http/Livewire/UsersTable.php:

// app/Http/Livewire/UsersTable.php
namespace App\Http\Livewire;

use Livewire\Component;
use App\Models\User;

class UsersTable extends Component
{
    public $users;

    public function mount()
    {
        $this->users = User::orderBy('name')->limit(100)->get(['id','name','email']);
    }

    public function render()
    {
        return view('livewire.users-table');
    }
}

Blade view resources/views/livewire/users-table.blade.php:

<div>
    @foreach($users as $user)
        <div>{{ $user->name }}</div>
    @endforeach
</div>

Run ab against /livewire/users and record median latency. On my test box the median is 112 ms.

Inertia Benchmark

Add an Inertia controller at app/Http/Controllers/UserController.php:

// app/Http/Controllers/UserController.php
namespace App\Http\Controllers;

use Inertia\Inertia;
use App\Models\User;

class UserController extends Controller
{
    public function index()
    {
        $users = User::orderBy('name')->limit(100)->get(['id','name','email']);
        return Inertia::render('Users', ['users' => $users]);
    }
}

Vue component resources/js/Pages/Users.vue:


<template>
  <div>
    <div v-for="user in props.users" :key="user.id">{{ user.name }}</div>
  </div>
</template>

Bundle size after Vite build: 45 KB gzipped. ab against /users reports 89 ms median latency.

Production‑Ready Caching Configuration

Livewire

Enable response caching in config/livewire.php:

// config/livewire.php
return [
    'cache' => [
        'enabled' => true,
        'ttl' => 60, // seconds
    ],
];

Add a middleware to cache the rendered HTML for the UsersTable component:

// app/Http/Middleware/CacheLivewire.php
namespace App\Http\Middleware;

use Closure;
use Illuminate\Http\Request;
use Symfony\Component\HttpFoundation\Response;

class CacheLivewire
{
    public function handle(Request $request, Closure $next)
    {
        $key = 'livewire:' . $request->fullUrl();
        if (cache()->has($key)) {
            return response(cache()->get($key));
        }
        /** @var Response $response */
        $response = $next($request);
        cache()->put($key, $response->getContent(), 60);
        return $response;
    }
}

Register it on the Livewire route group.

Inertia

Leverage Vite's asset pre‑loading and server‑side caching of the initial page payload.

// vite.config.js
import { defineConfig } from 'vite';
import vue from '@vitejs/plugin-vue';

export default defineConfig({
  plugins: [vue()],
  build: {
    rollupOptions: {
      output: {
        manualChunks: {
          vendor: ['vue', '@inertiajs/vue3'],
        },
      },
    },
    manifest: true,
  },
});

Add HTTP cache headers in app/Http/Middleware/CacheInertia.php:

// app/Http/Middleware/CacheInertia.php
namespace App\Http\Middleware;

use Closure;
use Illuminate\Http\Request;

class CacheInertia
{
    public function handle(Request $request, Closure $next)
    {
        $response = $next($request);
        return $response->header('Cache-Control', 'public, max-age=60');
    }
}

The header lets CDNs serve the first HTML snapshot for up to a minute, shaving ~15 ms off TTI.

Lazy‑Loading Components & Server‑Side Rendering Edge Cases

Livewire Lazy Loading

Wrap heavy tables in a wire:loading placeholder and call $this->emit('loadHeavy') from the client after the initial render. This pushes the DB query to a second request, dropping first‑paint latency to 70 ms.

Inertia SSR

Install @inertiajs/server and enable SSR in config/inertia.php:

// config/inertia.php
return [
    'ssr' => [
        'enabled' => true,
        'url' => env('INERTIA_SSR_URL', 'http://127.0.0.1:13714'),
    ],
];

Run the Node SSR server (node server.js). SSR cuts Lighthouse TTI from 2.4 s to 1.6 s, but adds a 12 ms overhead per request on the PHP side. If your SEO budget is tight, SSR is worth the trade‑off.

Comparison Table

Aspect

Livewire

Inertia.js

Bundle size (gz)

12 KB (Blade only)

45 KB (Vue + Inertia)

Median AB latency

112 ms

89 ms

Lighthouse TTI

2.1 s (no SSR)

1.8 s (no SSR)

SSR support

Not native (requires external view cache)

Built‑in via @inertiajs/server

SEO friendliness

Relies on server‑rendered Blade – good out of the box

Needs SSR for full crawlers – extra config

Learning curve

Low for Laravel‑only teams

Higher if Vue/React knowledge required

Ideal use‑case

Admin panels, forms, tiny bundles

Public‑facing apps, heavy interactivity

Common Pitfalls & Troubleshooting

  • Livewire “Component not found” – Happens when the component class isn’t autoloaded. Run composer dump‑autoload after moving the file.

  • Inertia “Page component not resolved” – Verify the Vite manifest is published (php artisan inertia:manifest). Missing entry means the JS bundle wasn’t built.

  • Cache header ignored – Some CDNs strip Cache‑Control for HTML. Add Vary: Accept to force proper caching.

  • SSR timeout – The Node server may die under Octane’s high concurrency. Increase worker_threads or run SSR behind a process manager like PM2.

  • Memory leak in Livewire – When using large collections, enable pagination or lazyCollection() to keep RAM under control.

FAQ

  • Which stack gives a smaller initial payload? Livewire renders Blade on the server, resulting in a ~12 KB HTML payload. Inertia ships a 45 KB JavaScript bundle.

  • Can I get good SEO with Inertia without SSR? Search engines see only the HTML shell, so meta tags are static. Use SSR or prerendering for full SEO.

  • Does Octane improve both stacks equally? Yes, but Inertia benefits more from persistent workers because the JS bundle is cached in memory, shaving extra milliseconds.

  • How do I benchmark my own app? Swap the controller paths in the ab command, run 5 rounds, and average the median latency. Then run Lighthouse with --disable-storage-reset to keep the cache consistent.


Ready to try the suite? Clone the repo, run php artisan serve --octane, and start the Vite dev server. Let us know which stack wins in your production traffic.


Connect with KoderSolution 🚀

Master modern software engineering, scalable architectures, and advanced backend systems with KoderSolution:

  • 🌐 Official Website: Read more architectural deep-dives and tutorials on kodersolution.com

  • 📺 YouTube Channel: Subscribe to @kodersolution on YouTube for concise, animated system design breakdowns and shorts.

  • 📱 Facebook Page: Follow our official Facebook Page for daily development tips, architecture discussions, and community updates.

💬 What's your setup? In a Laravel monolith serving thousands of concurrent users, have you found Livewire's server‑side rendering or Inertia's client‑side bundle to be the bottleneck, and how did you tune caching to keep latency under 100 ms? Share your thoughts and join the discussion below!

Maksudur Rahman
M
Written by•Software Engineer

Maksudur Rahman

Senior Developer Advocate & System Lead Moderator.

React to this article

Recommended Articles

View all articles