Further to Aryne's comments, the internal cache assertion was originally implemented to cache SOAP messages, but can be applied in a general sense for any content type. As such every cached object is stored as a message type variable with an associated contentType, so if you cache a string type variable then upon retrieval it will be a message type (text/plain) that will need to be converted back to a string variable in policy by referencing ${<varname>.mainpart}. The policy below illustrates this concept.
<?xml version="1.0" encoding="UTF-8"?>
<wsp:Policy xmlns:L7p="http://www.layer7tech.com/ws/policy" xmlns:wsp="http://schemas.xmlsoap.org/ws/2002/12/policy">
<wsp:All wsp:Usage="Required">
<L7p:CommentAssertion>
<L7p:Comment stringValue="* Internal cache demonstration policy"/>
</L7p:CommentAssertion>
<L7p:AuditAssertion/>
<L7p:SetVariable>
<L7p:Base64Expression stringValue="U29tZSByYW5kb20gc3RyaW5n"/>
<L7p:VariableToSet stringValue="foo"/>
</L7p:SetVariable>
<L7p:SetVariable>
<L7p:Base64Expression stringValue="Zm9v"/>
<L7p:VariableToSet stringValue="cacheKey"/>
</L7p:SetVariable>
<L7p:CacheStorage>
<L7p:AssertionComment assertionComment="included">
<L7p:Properties mapValue="included">
<L7p:entry>
<L7p:key stringValue="RIGHT.COMMENT"/>
<L7p:value stringValue="// Store the string to the cache"/>
</L7p:entry>
</L7p:Properties>
</L7p:AssertionComment>
<L7p:CacheEntryKey stringValue="${cacheKey}"/>
<L7p:OtherTargetMessageVariable stringValue="foo"/>
<L7p:Target target="OTHER"/>
</L7p:CacheStorage>
<L7p:CacheLookup>
<L7p:AssertionComment assertionComment="included">
<L7p:Properties mapValue="included">
<L7p:entry>
<L7p:key stringValue="RIGHT.COMMENT"/>
<L7p:value stringValue="// Retrieve from cache to ${bar}"/>
</L7p:entry>
</L7p:Properties>
</L7p:AssertionComment>
<L7p:CacheEntryKey stringValue="${cacheKey}"/>
<L7p:ContentTypeOverride stringValue=""/>
<L7p:OtherTargetMessageVariable stringValue="bar"/>
<L7p:Target target="OTHER"/>
</L7p:CacheLookup>
<L7p:HardcodedResponse>
<L7p:Base64ResponseBody stringValue="Zm9vPSR7Zm9vfQpiYXI9JHtiYXJ9CmJhci5tYWlucGFydD0ke2Jhci5tYWlucGFydH0KYmFyLmNvbnRlbnRUeXBlPSR7YmFyLmNvbnRlbnRUeXBlfQ=="/>
<L7p:ResponseContentType stringValue="text/plain; charset=UTF-8"/>
</L7p:HardcodedResponse>
</wsp:All>
</wsp:Policy>
------------------------------
Jay MacDonald - Adoption Architect - Broadcom API Management (Layer 7)
------------------------------
Original Message:
Sent: 04-28-2019 07:02 PM
From: Aryne Chee
Subject: Re: Can CA API GW cache static or dynamic content?
Hello @Ikwan-ca,
The API Management Gateway offers the capability of storing and retrieving messages or string in an internal cache on a Gateway node, using the Store to Cache Assertion and Look Up In Cache Assertion.
If you are looking at storing data in other format like files, there is a Tactical Assertion named Remote Cache Assertion which provides support for storing and retrieving messages from a remote cache server like Memcached, Coherence, Terracota, GemFire as well as Redis.
Please contact CA Support if you need further information about this Tactical Assertion.
Thanks,
Aryne