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(4mo ago)013MITPHPPHP ^8.1

Since Jan 12Pushed 4mo 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 1mo ago

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

37

—

LowBetter than 83% of packages

Maintenance78

Regular maintenance activity

Popularity5

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity49

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

121d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/092a8b57ed995393618ee9dbf2055d43060fef84a2c5b4ef4e305bab3ff5b432?d=identicon)[shadishammaa](/maintainers/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

[spatie/laravel-responsecache

Speed up a Laravel application by caching the entire response

2.8k8.2M51](/packages/spatie-laravel-responsecache)[genealabs/laravel-model-caching

Automatic caching for Eloquent models.

2.4k4.8M26](/packages/genealabs-laravel-model-caching)[mikebronner/laravel-model-caching

Automatic caching for Eloquent models.

2.4k127.1k1](/packages/mikebronner-laravel-model-caching)[laragear/cache-query

Remember your query results using only one method. Yes, only one.

272122.8k](/packages/laragear-cache-query)[mike-bronner/laravel-model-caching

Automatic caching for Eloquent models.

2.4k2.0k1](/packages/mike-bronner-laravel-model-caching)[torchlight/torchlight-laravel

A Laravel Client for Torchlight, the syntax highlighting API.

120452.8k11](/packages/torchlight-torchlight-laravel)

PHPackages © 2026

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