Loaded from

The MCache class manages the creation, storing, and retrieval of pages created by the framework. Specifying a page to cache happens at the controller level. The resulting cached HTML page is given a time to live, after which a new page is created and re-cached. Until the page is recreated the cached page is served. This can increase the speed of pages being loaded, while decreasing the timeliness of information being presented to the use. For some pages this trade-off is acceptable and preferable to increasing processing power and memory of the server running the application.

Public Methods


This function should be called at the top of a function withing a controller you would like to cache. The only parameter needed is the amount of minutes you want MogulPHP to serve a cache file before recaching the page.

For example to cache a page for 15 minutes you would add this within the function representing the page you want to cache.


Pages are chached into the cache directory within your application directory and are named using a md5 hashed concatinated string of all $_COOKIE, $_FILES, $_GET, $_POST, $_SESSION, and requested URL variables. This means that a cached pages receiving new $_GET, $_POST or any of the other superglobal variable will be recached rather than serve an existing cached page. This is useful for creating cached pages for different logged in users.