PHPackages                             phpwatch/laravel-fast404 - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. phpwatch/laravel-fast404

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

phpwatch/laravel-fast404
========================

A Laravel middleware to quickly terminate Page-Not-Found pages that do not require a full HTML page

v1.0.0(5y ago)661[1 PRs](https://github.com/PHPWatch/Laravel-Fast404/pulls)MITPHPPHP ^7.4

Since May 20Pushed 3y ago1 watchersCompare

[ Source](https://github.com/PHPWatch/Laravel-Fast404)[ Packagist](https://packagist.org/packages/phpwatch/laravel-fast404)[ Docs](https://github.com/PHPWatch/Laravel-Fast404)[ RSS](/packages/phpwatch-laravel-fast404/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (2)Versions (3)Used By (0)

[![Laravel Fast 404](https://camo.githubusercontent.com/402fd6d6e2d8e1f7a0345259a581024348ee4e171e844189bc379e9dc07cdf92/68747470733a2f2f73742e61796573682e6d652f66696c65732f636f64652f6c61726176656c2d666173743430342f6865616465722e706e67)](https://camo.githubusercontent.com/402fd6d6e2d8e1f7a0345259a581024348ee4e171e844189bc379e9dc07cdf92/68747470733a2f2f73742e61796573682e6d652f66696c65732f636f64652f6c61726176656c2d666173743430342f6865616465722e706e67)

Laravel Fast 404
================

[](#laravel-fast-404)

Laravel Fast 404 is a Laravel package that adds a global middleware to your Laravel application to immediately terminate HTTP(s) requests for non-HTML 404 requests. This prevents unnecessary database connections and your application from fully bootstrapping to serve an HTML page that nobody will see.

This is done by inspecting every incoming HTTP request's "Accept" header and the URI path. If the URI path ends with a known static file extension (such as `.jpg`, `.png`, `.woff`, etc), and the `Accept` header does not mention `text/html` (which is the case when browsers request images, web fonts, JS files, CSS files, etc), the request is immediately terminated by this middleware.

[![Latest Stable Version](https://camo.githubusercontent.com/5a1ab06cab198c468844d56036c717d25ddd8d94acf2047e33353760c1b17531/68747470733a2f2f706f7365722e707567782e6f72672f70687077617463682f6c61726176656c2d666173743430342f76)](https://packagist.org/packages/phpwatch/laravel-fast404) [![Total Downloads](https://camo.githubusercontent.com/44d9be992c36dcc1e9f456cf00357e0ec48540b8b5580897eccf104ea9e99722/68747470733a2f2f706f7365722e707567782e6f72672f70687077617463682f6c61726176656c2d666173743430342f646f776e6c6f616473)](https://packagist.org/packages/phpwatch/laravel-fast404) [![License](https://camo.githubusercontent.com/403dfc01ae6495dc8ebf8bac93c5be82a5e981959b9151c46bdd714529a4c7fc/68747470733a2f2f706f7365722e707567782e6f72672f70687077617463682f6c61726176656c2d666173743430342f6c6963656e7365)](https://packagist.org/packages/phpwatch/laravel-fast404) [![CI](https://github.com/PHPWatch/Laravel-Fast404/workflows/CI/badge.svg)](https://github.com/PHPWatch/Laravel-Fast404/workflows/CI/badge.svg)

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

[](#requirements)

- Laravel 5.5+, 6, or 7
- PHP 7.4

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

[](#installation)

```
composer require phpwatch/laravel-fast404
```

Upon installation, Laravel will automatically register the Service Provider bundled with this package, which will in turn register middleware and the `Fast404Middleware` service automatically.

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

[](#configuration)

You can configure the message, the regular expression used to match URI patterns (e.g. a list of file extensions), and optionally an exclusion regular expression.

### From configuration files

[](#from-configuration-files)

Update your `config/app.php` file, and add the following configuration to the existing array:

```
