Performance Optimization
Performance Optimization
Optimize your Flatboard 5 forum for the best performance. This guide covers caching, asset optimization, and performance tuning techniques.
Performance Overview
Flatboard 5 is designed for performance:
- Denormalized Counters - Fast statistics without complex queries
- Markdown Caching - Pre-rendered Markdown content
- Atomic File Operations - Safe concurrent file access
- Asset Optimization - Minified and combined assets
- Efficient Storage - Optimized JSON/SQLite access
Caching
Markdown Cache
Flatboard 5 caches rendered Markdown:
- Automatic Caching - Markdown is cached after first render
- Cache Invalidation - Cache cleared when content updated
- Performance Gain - Up to 70% faster page loads
Enable/Disable:
- Admin Panel > Settings > Performance > Enable Cache
Template Cache
Cache compiled templates:
- Faster Rendering - Templates compiled once
- Reduced CPU - Less processing per request
- Automatic Updates - Cache cleared on template changes
Cache Management
Clear Cache:
- Admin Panel > Tools > Cache > Clear Cache
Rebuild Cache:
- Admin Panel > Tools > Cache > Rebuild Cache
# Clear cache via CLI
php app/Cli/console.php cache:clear
# Rebuild cache
php app/Cli/console.php cache:rebuildAsset Optimization
CSS/JavaScript Minification
Flatboard 5 automatically minifies assets:
- Automatic - Minification happens automatically
- Cache Busting - Versioned filenames for cache invalidation
- Combined Files - Multiple files combined when possible
- Debug Mode Override - When debug mode is enabled, assets are not minified (served in original format for easier debugging)
Configuration:
- Admin Panel > Settings > Performance > Asset Optimization
Debug Mode Impact
When debug mode is enabled, asset minification is automatically disabled. This is intentional to facilitate debugging, but will impact performance. Always disable debug mode in production.
Image Optimization
Optimize images before upload:
- Compress Images - Use tools like TinyPNG
- Correct Formats - Use WebP when possible
- Appropriate Sizes - Resize to needed dimensions
- Lazy Loading - Load images on demand
CDN Integration
Use a CDN for static assets:
- Configure CDN - Set CDN URL in settings
- Upload Assets - Upload to CDN
- Update Paths - Update asset paths
- Test - Verify CDN delivery
Storage Optimization
JSON Storage
Optimize JSON storage:
- Regular Cleanup - Remove old/unused data
- Archive Old Content - Move old discussions to archive
- Optimize Structure - Keep JSON files organized
SQLite Optimization (Pro Edition)
Optimize SQLite database:
-- Vacuum database
VACUUM;
-- Analyze tables
ANALYZE;
-- Reindex
REINDEX;Via Admin Panel:
- Admin Panel > Tools > Database > Optimize
Storage Cleanup
Regular cleanup tasks:
# Clean old cache files
php app/Cli/console.php cleanup:cache
# Clean empty discussions
php app/Cli/console.php cleanup:empty-discussions
# Clean old storage
php app/Cli/console.php cleanup:storageServer Optimization
PHP Configuration
Optimize PHP settings:
; Increase memory limit
memory_limit = 256M
; Optimize opcache
opcache.enable = 1
opcache.memory_consumption = 128
opcache.max_accelerated_files = 10000
; Increase execution time if needed
max_execution_time = 60Web Server Configuration
Apache:
# Enable compression
<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css text/javascript application/javascript
</IfModule>
# Enable caching
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access plus 1 year"
ExpiresByType image/jpeg "access plus 1 year"
ExpiresByType image/png "access plus 1 year"
ExpiresByType text/css "access plus 1 month"
ExpiresByType application/javascript "access plus 1 month"
</IfModule>Nginx:
# Enable compression
gzip on;
gzip_types text/plain text/css application/json application/javascript text/xml application/xml;
# Enable caching
location ~* \.(jpg|jpeg|png|gif|ico|css|js)$ {
expires 1y;
add_header Cache-Control "public, immutable";
}Database Optimization (Pro Edition)
Indexes
Ensure proper indexes:
-- Check indexes
.schema
-- Create indexes if needed
CREATE INDEX idx_discussion_category ON discussions(category_id);
CREATE INDEX idx_post_discussion ON posts(discussion_id);
CREATE INDEX idx_user_email ON users(email);Query Optimization
Optimize queries:
- Use Indexes - Ensure indexes on frequently queried columns
- Limit Results - Use LIMIT for large result sets
- Avoid N+1 - Batch queries when possible
- Use Transactions - Group related operations
Monitoring Performance
Performance Metrics
Monitor key metrics:
- Page Load Time - Target: < 2 seconds
- Database Queries - Minimize query count
- Memory Usage - Monitor PHP memory
- CPU Usage - Watch server CPU
Tools
Browser DevTools:
- Network tab - Check load times
- Performance tab - Profile page rendering
Server Monitoring:
- PHP-FPM status
- Server resource usage
- Database query logs
Performance Testing
Test performance:
- Load Testing - Use tools like Apache Bench
- Profile Code - Use Xdebug profiler
- Monitor Logs - Check error and access logs
- User Feedback - Gather user experience feedback
Best Practices
General
- Enable Caching - Always enable caching in production
- Optimize Assets - Minify and compress assets
- Use CDN - Serve static assets from CDN
- Monitor Performance - Regular performance monitoring
Content
- Limit Post Length - Encourage concise posts
- Optimize Images - Compress images before upload
- Archive Old Content - Move old discussions to archive
- Regular Cleanup - Clean up old/unused data
Server
- Use PHP 8.1+ - Latest PHP versions are faster
- Enable OPcache - Enable PHP OPcache
- Use SSD Storage - Faster disk I/O
- Adequate Resources - Ensure sufficient RAM/CPU
Troubleshooting
Slow Page Loads
Check:
- Cache is enabled
- Assets are optimized
- Server resources adequate
- Database queries optimized
- Network latency
High Memory Usage
Solution:
- Increase PHP memory limit
- Optimize queries
- Reduce cache size
- Review plugins
Database Slow
Solution:
- Add indexes
- Optimize queries
- Vacuum database (SQLite)
- Consider JSON storage for small sites
Resources
- Configuration Guide - Performance settings
- Storage Guide - Storage optimization
- Troubleshooting - Performance issues
Last updated: February 23, 2026