---
schema_version: "1"
id: ce90071e96561385bf1b585bbddfe33566b97f6d0aa338f1d2eaf8be3e989fc6
title: Populate API Cache Best Practices
collection: admin
version: current
locale: en-us
portal_url: https://docs.salesforce.com/admin/current/en-us/ind/264-0-0/comms_populate_api_cache_best_practices.md
canonical_url: https://help.salesforce.com/s/articleView?id=ind.comms_populate_api_cache_best_practices.htm&release=264.0.0&type=5
source_site: help.salesforce.com
content_type: documentation
content_hash: a294578a209d353adf63150f05cfde2ab5dfef136719c96a0f7a75f7565e6b7b
description: Enhance the usability of Populate API cache by following the Populate API cache best practices whenever possible.
products:
  - Communications
  - Media
  - Energy and Utilities
release: "264"
---
# Populate API Cache Best Practices

Enhance the usability of Populate API cache by following the Populate API cache best practices whenever possible.

There are two scenarios where you populate the Cached API Response table:

- Cache Warmup: when there are no records in the CacheApiResponse table and you are populating it for the first time.
- Refresh API Cache: when you already have cached records but, you want to refresh the cache because of some changes in the Catalogs, Catalog Product Relationships (CPRs), Offers, and so on. Choose from one of the following options to refresh the API cache:
    
    - Run the Populate API Cache jobs, to populate or refresh the deltas (changes) only:
        
        This option is viable and efficient, when you have Catalog(s) with a huge number of Catalog Product Relationships (CPRs). It is also faster when compared to the other option (as it populates only deltas to accommodate recent changes).
        
        However, there could be minor problems encountered, for example, when a new CPR for an Offer is added to the Catalog, this Offer doesn't have any rule associated with it when you try to re-populate the cache without clearing the existing cached records. The newly added product has no rules defined on it, there is no need for it to be evaluated for Eligibility (as is considered default eligible). Since, the cache is not cleared and there exists an entry for the Cache Type catalogCtxEligibilityResult with no rule associated with the newly added Offer in the Catalog. The catalogCtxEligibilityResult is not be updated with the newly added Offer and will have the old list of eligible offers. This will throw an error, one or more offers are invalid, while performing the basket operations for the newly added offer in the catalog. If the cached entries are deleted and then re-populated the cache, the catalogCtxEligibilityResult would contain the correct set of entries of all eligible offers and this operation would work perfectly. To resolve such an issue, perform one of the workarounds mentioned in the below table.
        
        <table class="slds-table slds-table_bordered slds-max-medium-table_stacked slds-m-bottom_small ">
                <thead class="slds-text-title_caps ">
                  <tr><th class="slds-cell-wrap" scope="col" id="d243032e52">Workaround</th>
                  <th class="slds-cell-wrap" scope="col" id="d243032e54">Description</th>
                </tr></thead>
                <tbody><tr class="">
                  <td class="slds-cell-wrap" data-label="Workaround" headers="d243032e52">Call the getOffer API with the parameter forceinvalidatecache=true</td>
                  <td class="slds-cell-wrap" data-label="Description" headers="d243032e54">
                    <p>The API call deletes the existing stale catalogCtxEligibilityResult from the cache and replaces it with the updated entry of all eligible offers under catalogCtxEligibilityResult. This approach is the easiest solution to fix the issue.</p>
                  </td>
                </tr>
                <tr class="">
                  <td class="slds-cell-wrap" data-label="Workaround" headers="d243032e52">Delete the entry for record Type catalogCtxEligibilityResult from the CachedApiResponse table, and then perform the Basket Operation</td>
                  <td class="slds-cell-wrap" data-label="Description" headers="d243032e54">
                    <p>The basket operation will in-turn try to look for the eligibility of the offers being added and thereby add the entry for catalogCtxEligibilityResult in the table. The newly created entry will have correct populated eligible offers for catalogCtxEligibilityResult record type.</p>
                  </td>
                </tr>
              </tbody></table>
    - Delete all the existing cached entries and then re-populate the cache records:
        
        This option is considered to be the best practice, as everything populated in the cache has fresh entries. Both existing and recent changes are taken care of and there are no inconsistencies found later on while calling the APIs.