Block caching options

Block caching options

If you're developing a block you'll need to consider how that block might work with concrete5's caching model.


Snippet by Ollie / / Comments / Difficulty 
Block caching options

Caching can bring big speed improvements to your website, particularly if your database performance is a bottleneck. If you're building a block for your own, or others' use, you'll want to consider how your block should behave in caching scenarios and configure it respectively.

The following properties govern how a block interacts with concrete5's caching model. These properties should sit in the block's controller.php file

// Cache block's database calls
protected $btCacheBlockRecord = true;

// Cache block's actual view output
protected $btCacheBlockOutput = true;

// Serve cached version even if the result of a post request
protected $btCacheBlockOutputOnPost = true;

// Server cached version even if user is logged in
protected $btCacheBlockOutputForRegisteredUsers = true;

// Cache for CACHE_LIFETIME constant set in dashboard, or,
// set custom value in seconds
protected $btCacheBlockOutputLifetime = CACHE_LIFETIME; 

Join the conversation

comments powered by Disqus