PHPackages                             kudashevs/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. kudashevs/laravel-last-modified

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

kudashevs/laravel-last-modified
===============================

A Laravel middleware that handles the If-Modified-Since request and Last-Modified response headers.

v1.4.0(1y ago)0552↓50%MITPHPPHP ^8.1

Since Jan 11Pushed 1y ago1 watchersCompare

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

READMEChangelog (7)Dependencies (4)Versions (8)Used By (0)

Laravel Last Modified
=====================

[](#laravel-last-modified)

[![Latest Version on Packagist](https://camo.githubusercontent.com/867f2b8220d1f89d1e666bb504b4977e4e7b50f5d2d119acb22081c11cf9f62a/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6b75646173686576732f6c61726176656c2d6c6173742d6d6f6469666965642e737667)](https://packagist.org/packages/kudashevs/laravel-last-modified)[![Run Tests](https://github.com/kudashevs/laravel-last-modified/actions/workflows/run-tests.yml/badge.svg)](https://github.com/kudashevs/laravel-last-modified/actions/workflows/run-tests.yml)[![License MIT](https://camo.githubusercontent.com/784362b26e4b3546254f1893e778ba64616e362bd6ac791991d2c9e880a3a64e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4d49542d677265656e2e737667)](LICENSE.md)

This Laravel package contains a handler for the If-Modified-Since request and Last-Modified response headers.

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

[](#installation)

You can install the package via composer:

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

Then, register the middleware in the `app/Http/Kernel.php`:

```
protected $middleware = [
    'web' => [
        ...
        \Kudashevs\LaravelLastModified\Middleware\LastModified::class,
    ],
];
```

You may also want to publish the configuration file (optional).

```
php artisan vendor:publish --provider="Kudashevs\LaravelLastModified\Providers\LastModifiedServiceProvider"
```

After deploying your application, check whether [the headers are handled correctly](https://en.web-tool.org/check-last-modified/).

How it works
------------

[](#how-it-works)

First, the middleware identifies the last modification time of a given url by parsing the request. It tries to retrieve this information from possible origins in the following order (if it cannot retrieve the information, it moves forward):

- a first model in the view data,
- a first collection in the view data,
- a first paginator in the view data,
- a compiled view file,
- a view file,
- as a last resort, a fallback.

After the last modification time has been retrieved, the middleware sets the `Last-Modified` response header. Then, it handles the `If-Modified-Since` request header using the last modification time from the previous step.

Configuration
-------------

[](#configuration)

After [publishing](#installation), the configuration settings are located in the `config/last-modified.php` file.

There configuration options are currently supported:

```
'enable'               # A boolean defines whether the middleware is enabled (default `true`).
'aggressive'           # A boolean defines whether the middleware returns a response immediately (default is `false`).
'fallback'             # An integer the fallback timestamp for the Last-Modifier header.
'origins'              # An array with a list of origins of the last modification time.
'exclude'              # An array with a list of paths to be excluded from processing.

```

, for more information please see the [configuration](config/last-modified.php) file.

Testing
-------

[](#testing)

```
composer test
```

References
----------

[](#references)

- [RFC 7232: HTTP/1.1 Conditional Requests](https://datatracker.ietf.org/doc/html/rfc7232#section-3.3)
- [MDN If-Modified-Since](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/If-Modified-Since)

Contributing
------------

[](#contributing)

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

**Note:** Please make sure to update tests as appropriate.

License
-------

[](#license)

The MIT License (MIT). Please see the [License file](LICENSE.md) for more information.

###  Health Score

33

—

LowBetter than 75% of packages

Maintenance42

Moderate activity, may be stable

Popularity18

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity52

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~2 days

Total

7

Last Release

477d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/8cb0dfa9fab98bfb2cb6c697744ea5c1f7f57ffd6b0a498df6a17223912b617a?d=identicon)[Sergey Kudashev](/maintainers/Sergey%20Kudashev)

---

Top Contributors

[![kudashevs](https://avatars.githubusercontent.com/u/15892462?v=4)](https://github.com/kudashevs "kudashevs (92 commits)")

---

Tags

if-modified-sincelaravellast-modifiedlaravelhttp-headersif-modified-sinceLast-Modified

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/kudashevs-laravel-last-modified/health.svg)

```
[![Health](https://phpackages.com/badges/kudashevs-laravel-last-modified/health.svg)](https://phpackages.com/packages/kudashevs-laravel-last-modified)
```

###  Alternatives

[palanik/lumen-cors

Cross-origin resource sharing (CORS) middleware for Lumen micro-framework.

101237.4k](/packages/palanik-lumen-cors)[api-platform/laravel

API Platform support for Laravel

59126.4k6](/packages/api-platform-laravel)[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

1214.9k](/packages/abordage-laravel-last-modified)[laravel-shift/curl-converter

A command line tool to convert curl requests to Laravel HTTP requests.

935.3k](/packages/laravel-shift-curl-converter)[alfrasc/laravel-matomo-tracker

A Laravel facade/wrapper for the matomo/matomo-php-tracker for server side Matomo tracking.

1923.9k](/packages/alfrasc-laravel-matomo-tracker)[behamin/service-proxy

for proxy or sending requests to other services with useful utilities

102.2k](/packages/behamin-service-proxy)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
