Announcements
This site is in read only until July 22 as we migrate to a new platform; refer to this community post for more details.
Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

LookupCache Policy cannot find cache.

So I'm pretty sure my PopulateCache is working. As When I use the LookupCache in the request where I made the cache, I could see cache being populated on trace and on lookupcache, it assigns the cache it found to the proper variable. However, when I use the same lookupcache policy I used earlier on anothe proxy.

PS:

> My cache is not yet expired as i set it to 10 minutes, but when looking the value of the cache even before the 10 minutes expiry, lookupcache policy could still not find the cache.

> I already undeployed and reployed my code multiple times and clear the cache in the environment settings, but its still the same

This is my Populate Cache Policy

<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <PopulateCache name="PC-CodeChallenge">     <DisplayName>PC-CodeChallenge</DisplayName>
    <CacheKey>
        <KeyFragment ref="request.queryparam.code_challenge"/>
        <KeyFragment>CodeChallenge</KeyFragment>
    </CacheKey>
    <CacheResource>pkceCache</CacheResource>
    <!--<Source>proxy.code_challenge</Source>-->
    <Source>request.queryparam.code_challenge</Source>
    <!--<Source>request.queryparam.client_id</Source>-->
    <ExpirySettings>
        <!-- Access tokens expire after 10 minutes -->
        <TimeoutInSec>600</TimeoutInSec>
    </ExpirySettings>
    <!--<CacheResource>code_challenge</CacheResource>-->
</PopulateCache> 

This is my LookupCache Policy

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<LookupCache async="false" continueOnError="false" enabled="true" name="LC-CodeChallenge">
    <DisplayName>LC-CodeChallenge</DisplayName>
    <CacheKey>
        <KeyFragment ref="request.queryparam.code_challenge"/>
        <KeyFragment>CodeChallenge</KeyFragment>
    </CacheKey>
    <CacheResource>pkceCache</CacheResource>
    <AssignTo>code_challenge</AssignTo>
</LookupCache>

I also noticed that the action in my trace is always pause. (see screenshot attached).

All the while in my other proxy where this same policy work, its value is continue. What's seems to be the problem of why this is pausing then?.

Solved Solved
1 5 463
1 ACCEPTED SOLUTION

If you want to use cache across proxies then make use of the Scope tag in both policies.

 <Scope>Global</Scope>

Any other scope tag will also append the apiproxyname with the cache key and hence the cache cant be used on other proxies.

BTW you are using CacheResource so remove the <ExpirySettings> from Populate cache.

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<PopulateCache async="false" continueOnError="false" enabled="true" name="Populate-Cache-1">
    <DisplayName>Populate Cache-1</DisplayName>
    <Properties/>
    <CacheKey>
        <KeyFragment ref="request.queryparam.code_challenge"/>
        <KeyFragment>CodeChallenge</KeyFragment>
    </CacheKey>
    <CacheResource>pkceCache</CacheResource>
    <Scope>Global</Scope>
    <Source>request.queryparam.code_challenge</Source>
</PopulateCache>
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<LookupCache async="false" continueOnError="false" enabled="true" name="LC-CodeChallenge">
    <DisplayName>LC-CodeChallenge</DisplayName>
    <CacheKey>
        <KeyFragment ref="request.queryparam.code_challenge"/>
        <KeyFragment>CodeChallenge</KeyFragment>
    </CacheKey>
    <CacheResource>pkceCache</CacheResource>
    <AssignTo>code_challenge</AssignTo>
    <Scope>Global</Scope>
</LookupCache>

View solution in original post

5 REPLIES 5