PHPackages                             mohammedjalal99/filament-cache-plugin - 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. mohammedjalal99/filament-cache-plugin

ActiveLibrary[Caching](/categories/caching)

mohammedjalal99/filament-cache-plugin
=====================================

Complete caching solution for Filament PHP - Cache everything automatically

v1.0.9(10mo ago)101.0k1[2 issues](https://github.com/mohammedJalal99/filament-cache-plugin/issues)[1 PRs](https://github.com/mohammedJalal99/filament-cache-plugin/pulls)MITPHPPHP ^8.1CI failing

Since Aug 25Pushed 4mo agoCompare

[ Source](https://github.com/mohammedJalal99/filament-cache-plugin)[ Packagist](https://packagist.org/packages/mohammedjalal99/filament-cache-plugin)[ RSS](/packages/mohammedjalal99-filament-cache-plugin/feed)WikiDiscussions main Synced 3w ago

READMEChangelogDependencies (4)Versions (9)Used By (0)

🚀 Filament Cache Plugin
=======================

[](#-filament-cache-plugin)

[![Latest Version on Packagist](https://camo.githubusercontent.com/d07ed20353b860d44d2c89eb88e2d92c8e485ac7d95bc61d593e546194333ace/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6d6f68616d6d65644a616c616c39392f66696c616d656e742d63616368652d706c7567696e2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/mohammedJalal99/filament-cache-plugin)[![GitHub Tests Action Status](https://camo.githubusercontent.com/2207ce1eeded8db5ea9673821f058613ba3f6b4df56bcc2c09619ee1459c39d2/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6d6f68616d6d65644a616c616c39392f66696c616d656e742d63616368652d706c7567696e2f74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/mohammedJalal99/filament-cache-plugin/actions?query=workflow%3Atests+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/925cb9aa07cb6221ff901932e38beb06bb9da0ab25af98a6ce807dcfa41e6000/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6d6f68616d6d65644a616c616c39392f66696c616d656e742d63616368652d706c7567696e2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/mohammedJalal99/filament-cache-plugin)[![License](https://camo.githubusercontent.com/f091d65370c8a54114e52f6e0c3b91c78ce80ffd12ccffe672aff70d7e6d2b48/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6d6f68616d6d65644a616c616c39392f66696c616d656e742d63616368652d706c7567696e2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/mohammedJalal99/filament-cache-plugin)

 [![Filament Cache Plugin](https://raw.githubusercontent.com/mohammedJalal99/filament-cache-plugin/refs/heads/main/art/banner.svg)](https://raw.githubusercontent.com/mohammedJalal99/filament-cache-plugin/refs/heads/main/art/banner.svg)

**The ultimate caching solution for Filament PHP.** Supercharge your admin panels with intelligent, zero-config caching that works out of the box. Experience **10x faster page loads** and dramatically improved user experience.

✨ Why Choose This Plugin?
-------------------------

[](#-why-choose-this-plugin)

**🔥 Blazing Fast**
10x faster page loads with intelligent caching

**⚡ Zero Configuration**
Works immediately after installation

**🎯 Smart Caching**
Automatically detects what to cache

**🛡️ Cache Invalidation**
Intelligent cache busting when data changes

**📊 Performance Monitoring**
Built-in performance metrics

**🔧 Highly Configurable**
Fine-tune every aspect of caching

📊 Cache Management
------------------

[](#-cache-management)

Monitor and control your cache with built-in tools:

**Commands:**

```
# Check cache status
php artisan filament-cache:status

# Clear all caches
php artisan filament-cache:clear

# Monitor performance in real-time
php artisan filament-cache:monitor

# Generate performance report
php artisan filament-cache:report --export
```

**Performance Monitoring:**

```
// Get real-time metrics
FilamentCache::getMetrics();

// Returns: hit rate, response times, cache size, etc.
```

---

🎯 Real-World Example
--------------------

[](#-real-world-example)

Here's how easy it is to cache everything in your Filament resources:

```
// Before: Slow resource with heavy queries
class OrderResource extends Resource
{
    protected static function getEloquentQuery(): Builder
    {
        return parent::getEloquentQuery()
            ->with(['customer', 'items.product', 'payments'])
            ->withCount(['items', 'payments'])
            ->withSum('payments', 'amount');
    }

    public static function table(Table $table): Table
    {
        return $table->columns([
            TextColumn::make('total_revenue')
                ->getStateUsing(fn($record) =>
                    $record->calculateComplexRevenue() // Heavy calculation
                ),
        ]);
    }
}

// After: Lightning fast with zero config
class OrderResource extends Resource
{
    use CachesEverything; // 🚀 Add this trait

    protected static function getEloquentQuery(): Builder
    {
        return parent::getEloquentQuery()
            ->with(['customer', 'items.product', 'payments'])
            ->withCount(['items', 'payments'])
            ->withSum('payments', 'amount')
            ->cached(600); // ⚡ Cache for 10 minutes
    }

    public static function table(Table $table): Table
    {
        return $table->columns([
            TextColumn::make('total_revenue')
                ->cached(fn($record) =>
                    $record->calculateComplexRevenue() // Now cached!
                ),
        ]);
    }
}
```

**Result:** Page loads 10x faster with zero database queries on subsequent requests!

---

🎬 Performance Demo
------------------

[](#-performance-demo)

**Before vs After Performance:**

```
🐌 Without Plugin:    2.3s page load
🚀 With Plugin:       0.23s page load (10x faster!)

```

**What Gets Cached:**

- ✅ Database queries &amp; relationships
- ✅ Form select options &amp; dropdowns
- ✅ Navigation menus &amp; user menus
- ✅ Dashboard widgets &amp; statistics
- ✅ Table data &amp; computed columns
- ✅ Complete page responses
- ✅ File uploads &amp; media
- ✅ Notifications &amp; alerts

---

📦 Installation
--------------

[](#-installation)

### Step 1: Install the Package

[](#step-1-install-the-package)

```
composer require mohammedJalal99/filament-cache-plugin
```

### Step 2: Install Redis (Recommended)

[](#step-2-install-redis-recommended)

**🐧 Ubuntu/Debian**```
sudo apt-get update
sudo apt-get install redis-server

# Start Redis
sudo systemctl start redis
sudo systemctl enable redis

# Test Redis
redis-cli ping
# Should return: PONG
```

**🍎 macOS**```
# Using Homebrew
brew install redis

# Start Redis
brew services start redis

# Test Redis
redis-cli ping
# Should return: PONG
```

**🐳 Docker**```
# Run Redis container
docker run -d \
  --name redis-cache \
  -p 6379:6379 \
  redis:alpine

# Test Redis
docker exec -it redis-cache redis-cli ping
# Should return: PONG
```

**🪟 Windows**```
# Using Chocolatey
choco install redis-64

# Or download from: https://github.com/microsoftarchive/redis/releases
# Extract and run redis-server.exe

# Test Redis
redis-cli ping
# Should return: PONG
```

### Step 3: Configure Laravel

[](#step-3-configure-laravel)

Update your `.env` file:

```
# Cache Configuration
CACHE_DRIVER=redis
SESSION_DRIVER=redis
QUEUE_CONNECTION=redis

# Redis Configuration
REDIS_HOST=127.0.0.1
REDIS_PORT=6379
REDIS_PASSWORD=null
REDIS_DB=0

# Plugin Settings (Optional)
FILAMENT_CACHE_ENABLED=true
FILAMENT_CACHE_TTL=300
FILAMENT_CACHE_PAGES=true
```

### Step 4: Register the Plugin

[](#step-4-register-the-plugin)

Add to your Panel Provider (`app/Providers/Filament/AdminPanelProvider.php`):

```
