Caching System
Even with a highly optimized database layer, database hits carry a networking cost. Pragma CMS implements a multi-tier caching strategy to serve content at memory speeds.
1. Route Caching (O(1) Resolution)
Dynamic URL parsing using Regex is CPU-intensive. Pragma CMS compiles all dynamic routes and their database dependencies (like Content Type mappings) into a static PHP array stored on disk (/storage/cache/routes/).
When a request arrives, the router loads this array, benefiting directly from PHP's OPcache, making route resolution nearly instantaneous.
2. Page Caching (Full HTML)
(Core feature / Planned implementation)
For unauthenticated visitors (the vast majority of web traffic), Pragma CMS can capture the final compiled HTML from ob_get_clean() and write it directly to disk as a static .html file.
Subsequent requests bypass PHP entirely (served directly via Nginx/Apache) or are served by a lightweight PHP proxy in 1ms. The cache is automatically invalidated when an entry is updated in the Admin panel.
3. Asset Browser Caching
The CMS automatically sends Cache-Control: no-cache, must-revalidate headers for HTML to ensure content freshness, while allowing static assets (CSS, JS, Media) to leverage 304 Not Modified responses. This guarantees that returning visitors download almost zero bytes.