PHPackages                             abordage/laravel-last-modified - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [HTTP &amp; Networking](/categories/http)
4. /
5. abordage/laravel-last-modified

ActiveLibrary[HTTP &amp; Networking](/categories/http)

abordage/laravel-last-modified
==============================

Setting the Last-Modified header and 304 Not Modified response code if the page hasn't changed since the last visit

1.0.0(4mo ago)1214.9k↓11.1%5MITPHPPHP ^8.2CI passing

Since Jun 10Pushed 1mo ago2 watchersCompare

[ Source](https://github.com/abordage/laravel-last-modified)[ Packagist](https://packagist.org/packages/abordage/laravel-last-modified)[ Docs](https://github.com/abordage/laravel-last-modified)[ RSS](/packages/abordage-laravel-last-modified/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (8)Dependencies (6)Versions (12)Used By (0)

Last-Modified / 304 Not Modified Handler for Laravel
====================================================

[](#last-modified--304-not-modified-handler-for-laravel)

Easily setting the `Last-Modified` header and `304 Not Modified` response code.

[ ![Packagist Version](https://camo.githubusercontent.com/cffbad38a518baa6ab40497af5a815223e73bb5a67b40c5bb897cdc274b519f7/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f61626f72646167652f6c61726176656c2d6c6173742d6d6f646966696564)](https://packagist.org/packages/abordage/laravel-last-modified "Packagist version")[ ![GitHub Tests Status](https://camo.githubusercontent.com/61cf9e38ce8cb9afe6c05e116854a6782af6f3d968c74eefeeffe6bcd0b17b41/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f61626f72646167652f6c61726176656c2d6c6173742d6d6f6469666965642f74657374732e796d6c3f6c6162656c3d7465737473)](https://github.com/abordage/laravel-last-modified/actions/workflows/tests.yml "GitHub Tests Status")[ ![GitHub Code Style Status](https://camo.githubusercontent.com/56a021006ff84d6f368bfc8fa825ab79d47178060f07d518c85c6788188d5cbe/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f61626f72646167652f6c61726176656c2d6c6173742d6d6f6469666965642f7068702d63732d66697865722e796d6c3f6c6162656c3d636f64652532307374796c65)](https://github.com/abordage/laravel-last-modified/actions/workflows/php-cs-fixer.yml "GitHub Code Style Status")[ ![PHP Version Support](https://camo.githubusercontent.com/0608de4b5cdf09dbea1a6349ed7a1ed73088e3836d40b3af1e14ef53b717d76e/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f61626f72646167652f6c61726176656c2d6c6173742d6d6f646966696564)](https://www.php.net/ "PHP version")[ ![License](https://camo.githubusercontent.com/29e905d17573b1d7b68b95956d45741fceeeb672110b5c19859763274a1cea15/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f61626f72646167652f6c61726176656c2d6c6173742d6d6f646966696564)](https://github.com/abordage/laravel-last-modified/blob/master/LICENSE.md "License")

Requirements
------------

[](#requirements)

- PHP 8.2+
- Laravel 11.x / 12.x

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require abordage/laravel-last-modified
```

Optionally, you can publish the config file with:

```
php artisan vendor:publish --tag="last-modified-config"
```

Usage
-----

[](#usage)

The setup is very simple and consists of two steps:

### Registering middleware

[](#registering-middleware)

```
// in bootstrap/app.php

->withMiddleware(function (Middleware $middleware) {
    $middleware->web(append: [
        \Abordage\LastModified\Middleware\LastModifiedHandling::class,
    ]);
})
```

### Set Last Update Date in your Controller

[](#set-last-update-date-in-your-controller)

```
