swiftui-cached-async-image icon indicating copy to clipboard operation
swiftui-cached-async-image copied to clipboard

metrics.transactionMetrics.last?.resourceFetchType returns network instead of cache, but the first transactionMetrics have localCache

Open loryhuz opened this issue 1 year ago • 2 comments

Hi,

The CachedImageSync is playing animation even if the image comes from cache. After debugging I have metrics.transactionMetrics.count equal 2 and it returns resourceFetchType = .localCache in the first object, not the last one.

Do you have this as well or it's just me?

Thanks!

loryhuz avatar Dec 16 '23 11:12 loryhuz

After some investigations it comes from the default cache policies (which will return 2 transactions in some case, the first one is the cached one according to apple).

I opened a PR for this issue: https://github.com/lorenzofiamingo/swiftui-cached-async-image/pull/25

loryhuz avatar Dec 16 '23 12:12 loryhuz

I am not 100% sure but I think this is not the right fix. The reason why there are two values is that first the image was loaded from cache but was stale (expired) which is why the new data was fetched from the network resulting in two transaction values. In this case the animation should run, no?

dehlen avatar Jul 08 '24 18:07 dehlen