Change MODx Resources to Cacheable In Bulk

Whenever I edit a MODx page I usually find myself making it uncacheable so that I can temporarily make quick updates and see the page in its new form upon each refresh. The problem is that I sometimes forget to make the page cacheable again when I’m done editing.

If you are careless like me then the following snippet might be useful for changing your MODx resources to cacheable in bulk. To do this simply specify the ultimate parent of the resources you would like to cache, the depth to go when collecting the resources to cache, and the sort order.