PHPackages                             megaads/interceptor - 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. [Caching](/categories/caching)
4. /
5. megaads/interceptor

ActiveLibrary[Caching](/categories/caching)

megaads/interceptor
===================

Interceptor - Route Caching Engine for Laravel

1.0.30(1y ago)2774↓75%MITPHPPHP &gt;=5.6.4

Since Apr 6Pushed 3mo ago1 watchersCompare

[ Source](https://github.com/phult/interceptor-laravel)[ Packagist](https://packagist.org/packages/megaads/interceptor)[ Docs](https://www.megaads.vn)[ RSS](/packages/megaads-interceptor/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (33)Used By (0)

Interceptor - Route Caching Engine for Laravel
==============================================

[](#interceptor---route-caching-engine-for-laravel)

Interceptor is a powerful route caching module for Laravel, designed to boost application performance by caching full HTTP responses. It handles cache management, automatic garbage collection, and supports device-specific caching.

Features
--------

[](#features)

- **Full Response Caching**: Caches the entire HTTP response for defined routes.
- **Device Awareness**: Separately caches content for different devices (Desktop, Mobile, Tablet) or custom devices.
- **Redis &amp; File Storage**: tailored for Redis but supports file-based fallback.
- **Automatic Garbage Collection**: Automatically cleans up old or least recently used cache entries when limits are reached.
- **Smart Refresh**: Can refresh expired cache asynchronously.
- **Compression**: Built-in Gzip compression to save storage space.
- **Flexible Bypassing**: Configure rules to bypass cache based on Cookies, IPs, User Agents, Headers, or specific Routes.
- **Management Commands**: Artisan commands to flush, refresh, and monitor cache.

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

[](#requirements)

- PHP &gt;= 5.6.4
- Laravel Framework
- Redis (Recommended)

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

[](#installation)

Install via Composer:

```
composer require megaads/interceptor
```

### Registers Provider

[](#registers-provider)

**Laravel &gt; 5.5**: The package should be auto-discovered.

**Laravel &lt; 5.5**: Add the service provider to your `config/app.php`:

```
'providers' => [
    // ...
    Megaads\Interceptor\InterceptorServiceProvider::class,
],
```

### Publish Configuration

[](#publish-configuration)

Publish the configuration file to customize the settings:

```
php artisan vendor:publish --provider="Megaads\Interceptor\InterceptorServiceProvider"
```

Measurements generally will be available in `config/interceptor.php`.

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

[](#configuration)

The configuration file `config/interceptor.php` allows you to tweak various aspects:

- **enable**: Toggle caching globally.
- **maxCacheSize**: Maximum number of items in cache buffer before garbage collection kicks in.
- **refreshRate**: Time in seconds before a cache entry is considered "stale" (but still valid) and triggers a background refresh.
- **maxAge**: Time in seconds before a cache entry is considered expired and hard removed.
- **devices**: List of device types to categorize requests (e.g., 'desktop', 'mobile').
- **saveToFile**: Set to `true` to use file storage instead of Redis.
- **compress**: Enable Gzip compression.
- **bypasses**: Define rules to skip caching:
    - `cookies`: Skip if specific cookies are present.
    - `ips`: Skip specific IP addresses or ranges (wildcards supported).
    - `userAgents`: Skip specific User Agents (Regex supported).
    - `headers`: Skip based on request headers.
    - `routes`: Skip specific route patterns.

Usage
-----

[](#usage)

### Middleware

[](#middleware)

Apply the `interceptor` middleware to the routes or groups you want to cache in your `routes/web.php` or `routes/api.php`:

```
Route::group(['middleware' => 'interceptor'], function () {
    Route::get('/', 'HomeController@index');
    Route::get('/category/{slug}', 'CategoryController@show');
});
```

### Console Commands

[](#console-commands)

The package provides several Artisan commands for managing the cache:

- **Flush all cache**:

    ```
    php artisan interceptor:flush
    ```
- **Monitor cache stats**:

    ```
    # Check total cache count
    php artisan interceptor:monitor sum

    # List cache keys (optional device filter)
    php artisan interceptor:monitor list
    php artisan interceptor:monitor list mobile

    # Check specific URL keys
    php artisan interceptor:monitor check "https://example.com/foo"
    ```
- **Remove specific cache**:

    ```
    # Remove cache for a specific URL (all devices)
    php artisan interceptor:remove "https://example.com/foo"
    ```
- **Refesh specific cache**:

    ```
    # Refresh cache for a specific URL (all devices)
    php artisan interceptor:refresh url "https://example.com/foo"

    # Refresh out-of-date cache items (limit 10)
    php artisan interceptor:refresh outofdate 10
    ```
- **Manually trigger garbage collection**:

    ```
    php artisan interceptor:garbage
    ```

Headers
-------

[](#headers)

Interceptor adds the following headers to cached responses to help you debug:

- `Served-From`: `interceptor` (Indicates the response came from this package)
- `Interceptor-Cache-State`: `HIT` or `MISS`
- `Interceptor-Cache-Time`: Timestamp of when the cache was created.
- `Interceptor-Meta-Data`: JSON encoded metadata about the cache request.

License
-------

[](#license)

This project is licensed under the MIT License.

Contact us / Instant feedback
-----------------------------

[](#contact-us--instant-feedback)

Email:  |

If you find a bug, please report it here on Github

###  Health Score

40

—

FairBetter than 88% of packages

Maintenance62

Regular maintenance activity

Popularity19

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity58

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 ~44 days

Recently: every ~55 days

Total

31

Last Release

545d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/72ad425c743522a807fd15e2a7b0ada9c2a2127ecca76fbef37cf9292022006a?d=identicon)[megaads-vn](/maintainers/megaads-vn)

---

Top Contributors

[![phult](https://avatars.githubusercontent.com/u/4711640?v=4)](https://github.com/phult "phult (43 commits)")

---

Tags

responselaravelroutercacheroute

### Embed Badge

![Health badge](/badges/megaads-interceptor/health.svg)

```
[![Health](https://phpackages.com/badges/megaads-interceptor/health.svg)](https://phpackages.com/packages/megaads-interceptor)
```

###  Alternatives

[spatie/laravel-responsecache

Speed up a Laravel application by caching the entire response

2.8k8.2M51](/packages/spatie-laravel-responsecache)[awssat/laravel-visits

Laravel Redis visits counter for Eloquent models

975163.6k2](/packages/awssat-laravel-visits)[swayok/alternative-laravel-cache

Replacements for Laravel's redis and file cache stores that properly implement tagging idea. Powered by cache pool implementations provided by http://www.php-cache.com/

202541.1k6](/packages/swayok-alternative-laravel-cache)[maartenstaa/laravel-41-route-caching

This package allows you to cache your routes definitions, thereby speeding up each request.

25371.9k](/packages/maartenstaa-laravel-41-route-caching)[flc/laravel-middleware-cache-response

Laravel中间件-Response缓存

608.2k](/packages/flc-laravel-middleware-cache-response)[dragon-code/laravel-cache

An improved interface for working with cache

6844.8k10](/packages/dragon-code-laravel-cache)

PHPackages © 2026

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