Caching is a great functionality and drastically improves the performance of your Dynamics 365 Portal. However sometimes you just need to be sure that you’re working with realtime data.
To deliver optimal performance Dynamics 365 Portals do a great job in caching data. When it comes to Liquid fetchxml, whenever Dynamics 365 Portals executes a query it will cache the result of that query. But what if you need to bypass this caching mechanism?
Normally I’d tell you to go ahead and read this crm tip of the day which explains that you need to enable Entity Change Tracking. But sometimes the Entity Change Tracking isn’t covering your specific scenario. I can think of a couple of reasons why Change Tracking might not fit your needs:
- Virtual Entities.
- You’re On Prem with an old version (scary, right).
- You don’t trust Change Tracking.
- Custom development / actions done in RetrieveMultiple plugins;
In a recent project, it was the last bit that was giving us trouble. So here’s how we fixed it.
How it works
In order to bypass the caching, it’s important to understand how caching works in portals. Basically whenever you execute a request that retrieves data from Dynamics 365, your portal queries the data from Dynamics 365 and stores the result in its cache. That way, the next time an identical request comes in, the portal knows it doesn’t need to ask CRM again, because it still has that data in memory.
How we bypass it
So the solution in bypassing this, is simply ensuring that your query is unique. You can easily do this in Liquid FetchXml by applying a ‘fake’ filter condition on the createdon field. In the Code block below, we’ve added a criteria that will ensure the query to be different every second:
<condition attribute="createdon" operator="le" value='{{ "today" | date: "yyyy-MM-dd HH:mm:ss" }}' />
This condition always evaluates to true as the createdon field will always have a date in the past. This means that the condition won’t affect the expected result, but it will ensure that your query does not get stuck in the cache-zone.
Disclaimer: I do not recommend to bypass the cache. I strongly advise to keep all existing caching mechanisms in place. The article above merely illustrated how caching can be bypassed when needed.
[…] Bypass Dynamics 365 Portals Liquid Fetchxml caching – Thrives […]
this is an good option to bypass cache for some scenario.
[…] bericht Bypass Dynamics 365 Portals Liquid Fetchxml caching verscheen eerst op […]