PHPackages                             shammaa/laravel-intelligent-cache - 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. shammaa/laravel-intelligent-cache

ActiveLibrary[Caching](/categories/caching)

shammaa/laravel-intelligent-cache
=================================

An intelligent response caching package for Laravel with automatic invalidation and smart headers.

v1.0.9(5mo ago)013MITPHPPHP ^8.1

Since Jan 12Pushed 5mo agoCompare

[ Source](https://github.com/shammaa/laravel-intelligent-cache)[ Packagist](https://packagist.org/packages/shammaa/laravel-intelligent-cache)[ RSS](/packages/shammaa-laravel-intelligent-cache/feed)WikiDiscussions main Synced today

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

Laravel Intelligent Cache 🚀
===========================

[](#laravel-intelligent-cache-)

**Laravel Intelligent Cache** is a high-performance, context-aware response caching package. It is designed to significantly boost your application's speed and optimize SEO by intelligently managing `Cache-Control` headers and providing automatic cache invalidation.

---

🌟 Main Objectives
-----------------

[](#-main-objectives)

1. **Boost Speed:** Achieve near-zero TTFB (Time to First Byte) by caching full HTML responses.
2. **Improve SEO:** Automatically fix the `no-cache` issue that hurts Google rankings by providing proper caching headers.
3. **Always Fresh:** Keep content updated automatically. When you add a new article, the cache refreshes itself.

---

🛠 Installation
--------------

[](#-installation)

You can install the package via composer:

```
composer require shammaa/laravel-intelligent-cache
```

### Publish Config

[](#publish-config)

```
php artisan vendor:publish --provider="Shammaa\IntelligentCache\IntelligentCacheServiceProvider"
```

---

🚀 How to Use
------------

[](#-how-to-use)

### 1. The "Smart" Part (Auto-Update)

[](#1-the-smart-part-auto-update)

Add the `HasSmartCache` trait to any Model (like `Article.php`). This will automatically clear the cache whenever a new item is added or updated.

```
namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Shammaa\IntelligentCache\Traits\HasSmartCache;

class Article extends Model
{
    use HasSmartCache;
}
```

### 2. Speed Up Your Pages

[](#2-speed-up-your-pages)

#### Option A: Global Registration (Recommended)

[](#option-a-global-registration-recommended)

To solve the `no-cache` issue site-wide, you must register the middleware at the **beginning** of the stack (Outermost). This ensures it overrides any headers set by other middlewares (like Session).

**Laravel 11 (`bootstrap/app.php`):**

```
->withMiddleware(function (Middleware $middleware) {
    $middleware->web(prepend: [ // Use PREPEND here
        \Shammaa\IntelligentCache\Http\Middleware\CacheResponse::class,
    ]);
})
```

**Laravel 10 &amp; 9 (`app/Http/Kernel.php`):**Add it at the **TOP** of your `web` middleware group:

```
protected $middlewareGroups = [
    'web' => [
        \Shammaa\IntelligentCache\Http\Middleware\CacheResponse::class, // Put it at the top
        // ... other middlewares
    ],
];
```

#### Option B: Route Specific

[](#option-b-route-specific)

Alternatively, apply it to specific routes using the automatically registered alias `smart_cache`:

```
Route::middleware(['smart_cache'])->group(function () {
    Route::get('/articles', [ArticleController::class, 'index']);
});
```

---

⚙️ Configuration
----------------

[](#️-configuration)

You can find the settings in `config/intelligent-cache.php`:

- `lifetime`: How long to keep the cache (in seconds).
- `exclude`: URL patterns that should never be cached (like `/admin/*`).
- `headers`: Custom cache rules for browsers and Google.

---

📈 Performance Impact
--------------------

[](#-performance-impact)

- **LCP (Largest Contentful Paint):** Faster server responses lead to better user experience scores.
- **TTFB (Time to First Byte):** Eliminates database overhead for repeat visitors.

---

License
-------

[](#license)

The MIT License (MIT). Created with ❤️ by **Shammaa**.

###  Health Score

35

—

LowBetter than 77% of packages

Maintenance70

Regular maintenance activity

Popularity5

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity50

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

Total

10

Last Release

173d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/5834300?v=4)[shadishammaa](/maintainers/shadishammaa)[@shadishammaa](https://github.com/shadishammaa)

---

Top Contributors

[![shammaa](https://avatars.githubusercontent.com/u/8601466?v=4)](https://github.com/shammaa "shammaa (10 commits)")

### Embed Badge

![Health badge](/badges/shammaa-laravel-intelligent-cache/health.svg)

```
[![Health](https://phpackages.com/badges/shammaa-laravel-intelligent-cache/health.svg)](https://phpackages.com/packages/shammaa-laravel-intelligent-cache)
```

###  Alternatives

[mike-bronner/laravel-model-caching

Automatic caching for Eloquent models.

2.4k91.0k1](/packages/mike-bronner-laravel-model-caching)[spatie/laravel-responsecache

Speed up a Laravel application by caching the entire response

2.8k9.0M69](/packages/spatie-laravel-responsecache)[laravel/pulse

Laravel Pulse is a real-time application performance monitoring tool and dashboard for your Laravel application.

1.7k15.1M132](/packages/laravel-pulse)[psalm/plugin-laravel

Psalm plugin for Laravel

3355.3M346](/packages/psalm-plugin-laravel)[roots/acorn

Framework for Roots WordPress projects built with Laravel components.

9762.4M131](/packages/roots-acorn)[iazaran/smart-cache

Smart Cache is a caching optimization package designed to enhance the way your Laravel application handles data caching. It intelligently manages large data sets by compressing, chunking, or applying other optimization strategies to keep your application performant and efficient.

21111.6k](/packages/iazaran-smart-cache)

PHPackages © 2026

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