eZ Community » Learn » eZ Publish » eZ Publish Cache In Details:...

eZ Publish Cache In Details: Template-block Cache

Thursday 02 May 2013 8:56:14 am

  • Currently 3 out of 5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

How to expire template-block caches?

The previous chapter detailed the methods of automatic expirations of "template-block", according to the different directives (2 hours by default, expiry, subtree_expiry, ignore_content_expiry, etc.).

There is one other mode of expiration of "template-block" caches with a PHP command:

Expiration of all template-blocks (even those related to a subtree_expiry), by updating the timestamp of 'global-template-block-cache' in the {varDir}/expiry.php file

 php bin/php/ezcache.php --clear-id=template-block

 

However, this command is relatively risky when it comes to expire "template-blocks" only related to a single directive of "cache-block", which ultimately could be only a small proportion of the "template-blocks" to expire. The charge involved in the reconstruction of all the "template-blocks" (see simulation in the dedicated chapter) is often disproportionate in relation to the update to be performed.

A good practice is to always position markers within the "cache-blocks" to facilitate their research in command line:

{cache-block ignore_content_expiry expiry=0}
   <!-- ID:BLOCK1 -->
   ...
{/cache-block}

 

List all template-blocks created since 1 minute, having the string ID:BLOCK1

find var/myvardir/cache/template-block/ -mmin -1 -name "*.cache" -exec grep -iHl "ID:BLOCK1" {} \;

Remove all template-blocks created since 1 minute, having the string ID:BLOCK1

find var/myvardir/cache/template-block/ -mmin -1 -name "*.cache" -exec grep -iHl "ID:BLOCK1" {} \; | xargs rm
 

Ninja Method - Clear one Specific Cache Block

The following script allows you to clear one specific cache block: https://gist.github.com/gandbox/3634261

 

 
36 542 Users on board!

Tutorial menu

Printable

Printer Friendly version of the full article on one page with plain styles

Author(s)

Proudly Developed with from