Cache Management
Unfold CMS includes a cache management system that supports multiple drivers and provides admin panel controls for viewing, configuring, and clearing caches.
Overview
The cache system provides:
- Multiple drivers — File, Redis, and database caching
- Two-tier caching — L1 (in-memory request cache) + L2 (persistent cache)
- Response caching — Cache full HTTP responses for static pages
- Admin controls — Clear caches, view statistics, change drivers
- View/route/config caching — Laravel's built-in optimization caches
Configuration
Configure caching in Settings > Cache in the admin panel.
Cache Drivers
| Driver | Description | Best For |
|---|---|---|
file |
File-based cache | Shared hosting, small sites |
redis |
Redis in-memory cache | VPS/dedicated, high traffic |
database |
Database-backed cache | When file system is unreliable |
The default file driver works on all hosting environments including shared hosting.
Two-Tier Cache Architecture
Unfold CMS uses a two-tier caching strategy:
L1 Cache (Request Memory)
- In-memory cache that lasts for the current request only
- Prevents redundant database queries within a single page load
- No configuration needed — always active
L2 Cache (Persistent)
- Persistent cache using the configured driver (file, Redis, database)
- Survives across requests
- TTL-based expiration
When reading a cached value:
- Check L1 (instant, in-memory)
- If miss, check L2 (fast, persistent)
- If miss, query the database and store in both L1 and L2
Response Caching
Full HTTP responses can be cached using spatie/laravel-responsecache. When enabled, the CMS caches entire page responses for anonymous visitors, dramatically reducing server load.
Response caching is automatically bypassed for:
- Authenticated users
- POST/PUT/DELETE requests
- Pages with flash messages
- Admin panel routes
Admin Panel
Cache Statistics
Navigate to Tools > Cache in the admin panel to view:
- Current cache driver
- Cache status (enabled/disabled)
- Approximate cache size
- Last cache clear time
Clearing Caches
The admin panel provides buttons to clear specific caches:
| Cache | Command | Purpose |
|---|---|---|
| Application Cache | cache:clear |
Clears all cached data |
| View Cache | view:clear |
Clears compiled Blade views |
| Route Cache | route:clear |
Clears cached routes |
| Config Cache | config:clear |
Clears cached configuration |
| All Caches | All of the above | Complete cache reset |
When to Clear Caches
Clear caches when:
- You've made changes to configuration files
- Template files have been modified
- After updating the CMS
- When troubleshooting display issues
- After changing
.envvalues (requiresconfig:clear)
Production Optimization
For production servers, enable all optimization caches:
php artisan config:cache # Cache configuration
php artisan route:cache # Cache routes
php artisan view:cache # Cache Blade views
Note: After caching config, changes to
.envorconfig/files require runningphp artisan config:cacheagain to take effect.
Shared Hosting
The file driver works on all shared hosting environments. No additional setup is required.
For Redis caching on shared hosting, check if your host provides Redis access. Many modern shared hosts include Redis as an add-on.
Related
- Configuration — Cache settings reference
- Maintenance Mode — Clear caches after maintenance
- Shared Hosting — Cache considerations for shared hosting