woocommerce-ios icon indicating copy to clipboard operation
woocommerce-ios copied to clipboard

Add support for force-refreshing the server-side analytics cache

Open coreymckrill opened this issue 3 years ago • 1 comments
trafficstars

https://github.com/woocommerce/woocommerce/pull/33325 will add a new parameter to wc-analytics API endpoints, force_cache_refresh, which will cause the current request to bypass the cache, re-run the queries for the requested data, and overwrite the previous cache entry with the new results. The motivation behind this change is to make it possible to refresh cached data from the apps without having to resort to cache-busting parameter hacks.

The new parameter will be implemented hopefully at the same time as some changes to the TTL of the cached data, making it more likely that a request will return cached data rather than running expensive, slow queries. Since this could also result in cached data occasionally being "stale", the main use case, I think, for this new API parameter would be to include it in an analytics request when the user does a "pull to refresh". This way, if the user looks at e.g. their revenue stats, and thinks something is not quite right, they can refresh the screen and ensure that the stats they're seeing are up-to-date. There might be other use cases as well.

Usage: wc-analytics/reports/orders/stats?force_cache_refresh=true

Note that these changes will not be available in WooCommerce until probably 6.7.0. The reason for implementing this in the apps now is so that when the TTL changes also land in 6.7.0, the apps will be able to handle potentially stale data. In the mean time, if an API request includes force_cache_refresh=true but the store doesn't yet support it, the parameter will just be ignored.

coreymckrill avatar Jun 08 '22 21:06 coreymckrill

Related: https://github.com/woocommerce/woocommerce-android/issues/6719

coreymckrill avatar Jun 08 '22 21:06 coreymckrill