At times, changing the metadata (removing old fields, creating new fields, changing a User profile) may lower the performance of the application or display errors due the API Cache referring to the old fields as they are unavailable. To avoid this from happening, you may need to clear the API Cache from time to time for better performance. You can clear the cache in two ways:
- Use the Clear API Cache button on the Storefront record
- Schedule a batch job
To clear API cache from the Storefront
Click All tabs and click Storefronts.
Select your Storefront from the available list.
Click the Clear API Cache button. The API Cache clearing process begins. An apex job is triggered to clear the cache records related to the selected storefront.
- After the cache is cleared, the remaining cache data is displayed in the Cache Size field on the Storefront record.
To schedule a batch job to delete cache records
- Go to Setup and in the Quick Find box, type apex class.
- Click Apex Classes.
- Click the Schedule Apex button.
- In Job Name, type a unique name. For example, Schecdule job to clear api cache.
- In Apex Class, search and select DCClearCacheDispatcher.
- From the Schedule Apex Execution section, set the frequency as below:
- Select Weekly and select all the 7 days of the week.
- Specify a Start date.
- Specify an End date
- From the Preferred Start Time, set the time for 24 hrs. For example, 12:00 AM.
- Click Save.
This scheduled job executes every 24 hours looking for any profile changes in the last 24 hours and deletes any APICache records associated to those profiles.