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 - Cache-busted assets (
?v=<mtime>) with a long-livedimmutablebrowser cache - 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:clearAsset Optimization
CSS/JavaScript Delivery
Static theme and plugin assets are served and cache-managed by AssetLoader:
- CSS served as source - File-level CSS minification is currently forced off in
AssetLoader(the minifier broke some rules), so theme/plugin.cssis delivered unchanged. JS minification follows theassets.minify_jssetting, and any.min.css/.min.jsshipped alongside a source file is served as-is. Inline<style>/<script>blocks (viaInlineAssetHelper) are always minified. - Cache busting (since 5.7.2) - Every asset URL carries a
?v=<filemtime>query string, so the long-livedimmutablebrowser cache (Cache-Control: max-age=31536000, immutableset in.htaccess/nginx) still serves the fresh file the moment it changes — no manual cache clear needed after a deploy or edit. This covers plugin assets too, sincePluginAssetHelperdelegates toAssetLoader.
The
?v=<mtime> cache-buster makes the aggressive immutable static-cache header safe. Because the URL changes whenever a file changes, returning visitors never get stale CSS/JS after an update.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:
# Remove obsolete files in stockage/
php app/Cli/console.php cleanup:stockage
# Remove duplicate post files
php app/Cli/console.php cleanup:duplicate-posts
# Purge old anonymous visitor entries
php app/Cli/console.php cleanup:visitorsServer 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 = 60OPcache and deployments *(since 5.7.1)*
With OPcache enabled, PHP serves compiled bytecode and won't pick up updated
.php files until the cache is cleared — the classic "my fix isn't showing up in production" trap. Applying an update from Admin → Updates now flushes OPcache automatically, and Admin → Maintenance → Clear cache calls opcache_reset() too. After a manual deploy, hitting "Clear cache" once is enough to load the new code; no shell access or php-fpm reload required.Web 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