How To Configure a Trigger to Clear Cache on Updated Assets
28 Sep 2016 By Bartek Banda For version 22.214.171.124
This tutorial has been superseded by a setting on the Details screen of the Cache Manager called "Clear Asset Cache Automatically". Using this setting removes the need to create this type of cache clearing trigger.
This tutorial will show you how to configure a global Trigger to clear the Matrix Cache of assets whenever they are updated.
To configure the Trigger, follow these steps:
- Create a new Trigger asset.
- Set the Status to Enabled and enter a Name and Description, for example:
- In the Events section, select the Asset Updated event.
- Leave the Conditions section empty. The main reason for this is that it will make the Trigger very fast to execute. We want to clear the cache on any asset after it has been updated and it doesn't matter if it clears it when we don't really need it to.
- In the Actions section, select the Clear Matrix Cache Trigger Action and click Commit. You should now see the configuration area for this Trigger Action as shown in the example below:
- Enable the Ignore Permissions field to ignore the access rights of the user/s firing this trigger so that cache can be successfully cleared on all asset's that get updated by the user.
To confirm that the Trigger works, you can test it by editing the contents of a Standard Page and saving the screen. Afterwards, check the system log in the Log Manager and you should see entries similar to this:
[trigger.event_log - assetid:17:1;] (Trigger Execution Success) - SUCCESS Trigger "Clear Matrix Cache" (#1), Event: "trigger_event_asset_updated" broadcast by Asset: "About Us" (#7101))
- Server Side JS
- Squiz Edge
Write a Tutorial
Help us build a healthy library of useful tutorials for the Matrix Community.