How does cache / caching data works in Elements Connect?
Default value
By default, the cache duration for a data source is set to 5 minutes (300 seconds).
This default setting applies to all fields associated with the data source as well, unless a specific override is set at the field level. Cache can either be disabled by setting the field duration to null or it can be customized with a value greater than zero.
Importantly, changes to cache duration affect future caching behavior and do not invalidate existing cached data; the cache will only be invalidated upon expiration.
An example
Let's take the example of a Connected item "Asset" connected to a data source.
When "Asset" is edited:
Elements Connect evaluates the item query (and replaces dependencies by their value, if any)
Then, the app looks up in the cache for an entry matching the "Item/Evaluated Query" key
If an entry is found in the cache, it retrieves the response directly from the cache
If there is no entry in the cache, it executes the query on the datasource
If the request is successful, it stores the raw response in the cache associated with the key "Item/Evaluated query"
Otherwise, nothing is stored in the cache