SAP Gateway and OData Cache Clearing Ways in SAP Fiori Apps

SAP Gateway and OData Cache Clearing Ways in SAP Fiori Apps

SAP Gateway is a key component in the SAP Fiori landscape, responsible for providing a secure and efficient communication layer between SAP systems and external applications. One of the main features of SAP Gateway is its ability to expose SAP backend data to external applications using the OData protocol.



In SAP Fiori, caching is used to improve app performance by storing data and resources in temporary storage. However, sometimes these caches can become outdated or corrupted, leading to issues with the app. In such cases, clearing the cache becomes necessary to resolve the problem. 

When utilizing SAP Fiori apps, it is essential to understand how to clear the OData cache in order to ensure that the data presented is up-to-date and accurate. In this blog, we will explore the different cache clearing methods available for SAP Gateway and OData.


1. Cache Busting Technique

Cache busting is the technique of adding a unique identifier to the URL of the resource being requested. This forces the browser to make a new request for the resource, rather than relying on the cached copy. This method is typically used when there are changes made to the UI or data model, and you want to make sure that the user sees the latest version of the app.


To use cache busting in SAP Fiori, you can add a parameter to the end of the URL that contains a random value. For example:


```

/sap/opu/odata/sap/Z_MY_ODATA_SRV/MyEntitySet?$filter=Field eq 'Value'&cacheBuster=12345

```


This will force the browser to make a new request for the data, even if a cached copy is available.


2. Cache Invalidation

Cache invalidation is the process of removing a cached resource from the cache. This is typically done when the cached resource is no longer valid, such as when data has been updated or deleted. In SAP Fiori, cache invalidation can be done by sending a DELETE request to the cache.


To invalidate the cache in SAP Fiori, you can use the following URL:


```

/sap/opu/odata/sap/Z_MY_ODATA_SRV/$metadata?sap-cache-control=invalidate

```


This will invalidate the cache for the entire service, forcing the browser to request all resources again.


3. Cache Timeouts

Cache timeouts are used to specify how long a resource should be cached before it is considered stale and needs to be refreshed. In SAP Fiori, cache timeouts can be set using the SAP Gateway Service Builder.


To set a cache timeout in SAP Gateway, navigate to the Service Builder and select the service you want to configure. Then, go to the "Technical Settings" tab and set the cache timeout value in the "Caching" section.


4: /ui2/invalidate_global_caches

This method to clear cache in SAP Fiori apps is to use the transaction code /ui2/invalidate_global_caches. This method clears all the global caches, including the SAP Fiori cache, UI cache, OData cache, and others. 


To clear cache using this method, follow the below steps:


1. Open the SAP Fiori launchpad and log in with your credentials.

2. Open a new tab in the browser and enter the transaction code /ui2/invalidate_global_caches.

3. Click on the Execute button or press F8.

4. A pop-up window will appear, asking you to confirm the cache invalidation. Click on Yes to proceed.

5. Wait for the process to complete. The time taken to clear the cache will depend on the size of the cache.


5: /iwbep/cache_cleanup

This method to clear cache in SAP Fiori apps is to use the transaction code /iwbep/cache_cleanup. This method clears the OData cache, which stores metadata and data for OData services.


To clear cache using this method, follow the below steps:


1. Open the SAP Fiori launchpad and log in with your credentials.

2. Open a new tab in the browser and enter the transaction code /iwbep/cache_cleanup.

3. Click on the Execute button or press F8.

4. A pop-up window will appear, asking you to confirm the cache cleanup. Click on Yes to proceed.

5. Wait for the process to complete. The time taken to clear the cache will depend on the size of the cache.


Conclusion

Clearing the OData cache is an essential task when working with SAP Fiori apps. By utilizing the cache busting, cache invalidation, and cache timeout techniques, you can ensure that your apps are always presenting accurate and up-to-date data to the user.

Previous
Next Post »