lorenzofiamingo / swiftui-cached-async-image

CachedAsyncImage is the simplest way to add cache to your AsyncImage.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

loryhuz opened this issue · 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!

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:
#25

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?