Отправка заголовка Last-Modified, статуса 304 Not Modified на Laravel

1. Установка пакета:

composer require abordage/laravel-last-modified

2. Регистрация middleware:

// in app/Http/Kernel.php

protected $middleware = [
    'web' => [
        // ...
        
        \Abordage\LastModified\Middleware\LastModifiedHandling::class,
    ],
    
    // ...
];

3. Установка last-modified в контроллере:

namespace App\Http\Controllers;
 
use App\Http\Controllers\Controller;
use App\Models\Post;
use LastModified;
 
class PostController extends Controller
{
    public function show($id)
    {
        $post = Post::findOrFail($id);

        LastModified::set($post->updated_at);
        
        return view('posts.show', ['post' => $post]);
    }
}

Подробнее: https://github.com/abordage/laravel-last-modified