I wanted to share how we are utilizing the power of CodeIgniter 4 in our project, SHONiR CMS, to achieve high-speed content delivery (100k+ requests) even on low-end shared hosting environments.
One of our core philosophies is: Don't touch the core. We believe the CI4 team is elite and the framework is already one of the most stable PHP foundations available. Instead of modifying core files, we focused on "utilizing" the framework's native power more efficiently.
How it Works: The Triple-Layer Cache Architecture To maintain high performance without expensive infrastructure, SHONiR CMS implements three distinct layers:
Native CI4 Web Page Caching We use the built-in $this->cachePage(300) functionality. It’s a "work like charm" feature that handles the generated output of a page, bypassing controller logic on subsequent hits. Reference: CodeIgniter 4 Caching User Guide: codeigniter.com/user_guide/general/caching.html
Static HTML Caching (The DB Killer) For sites like business portfolios or catalogs that don't update every minute, querying the database for every hit is a waste of resources.
Mechanism: SHONiR generates a fully rendered HTML file and stores it in writable/cache/htmls.
The Result: On request, the system delivers the static HTML directly. No DB connection, no heavy PHP processing.
Traceability: We inject generation timestamps into the source code for developer transparency:
Converts images to WebP extension.
Compresses files to reduce size while maintaining visual quality.
Stores them in a dedicated image cache (Controlled via tbl_config).
Real-World Performance In our testing, even on average servers, the memory usage remains incredibly low: Usage: 659.19 kb | Peak: 659.73 kb
How to Configure (For CI4 Newbies) We’ve made activation simple via the database (tbl_config) and the .env file:
Global Cache Time: In tbl_config, set cache_time to your desired seconds (e.g., 3600 for 1 hour). Setting this to 0 clears/disables the cache.
Enable HTML Cache: In your .env, simply set html.cache = true.
Image Quality: Control the compression ratio (0-100) via the image_quality key in the config table.
Conclusion By keeping a Clean Architecture and respecting the CI4 core, we’ve built a system that is both maintainable and incredibly fast. It’s proof that you don’t need a complex stack to handle massive traffic—you just need to use CodeIgniter the right way.
Check out a live cached demo: 8.shonir.com/shonir-cms/bpd17/multi-cdn-guide-boo…
Would love to hear your thoughts or answer any questions about our implementation!
No responses yet.