Avoid AIM errors when using intermediate caching

Release 1.4 - ...

Intermediate caching scenarios are becoming more and more popular, because they make performance gains easy without flexibility loss.

Consider this SXML snippet. The first part saves a DataTable into cache:

Smartsite SXML CopyCode image Copy Code
<se:cache maxage="00:20:00" resulttype="none" save="key = this.getcachekey()">
  <se:xlinks parent="TEST_CONTENT" resulttype="datatable" />
</se:cache>

The second part uses the cached datatable for formatting:

Smartsite SXML CopyCode image Copy Code
<se:format inputdata="key">
  <se:rowformat>
     {this.field(title)}<br />
  </se:rowformat>
</se:format>

A pitfall here is the AIM scenario. Since cache creation is bypassed in AIM rendering mode, the cache key generation will not take place, and the second SXML part will fail during AIM rendering.

Luckily, there's a very simple fix for this: use the condition attribute and request.isaimrequest():

Smartsite SXML CopyCode image Copy Code
<se:format inputdata="key" condition="!request.isaimrequest()">
  <se:rowformat>
     {this.field(title)}<br />
  </se:rowformat>
</se:format>