candlefinance / faster-image

Fast image loading for React Native backed by performant native libraries.
https://candle.fi/discord
MIT License
486 stars 21 forks source link

clearCache does not clear cache completely #49

Open jamesholcomb opened 3 days ago

jamesholcomb commented 3 days ago

"@candlefinance/faster-image": "1.6.2"

on iOS 17 (both device and simulator), calling clearCache() seems to only partially work. I don't see a pattern, but some (most?) of the sources do indeed reload from network. The returned promise always resolves.

In my scenario, I cache static images from an API whose requests look like:

https://api.mapbox.com/styles/v1/mapbox/outdoors-v11/static/pin-s-star+FF0000(-95.98435239999999,36.1040077)/-95.98435239999999,36.1040077,15.5/393x130@2x?access_token=pk.eyJ1xxxxxxx&attribution=false&logo=true

is it possible to return information about the network request (or cache hit) in the onSuccess handler? That might help diagnose caching issues.

❯ npx react-native info
info Fetching system and libraries information...
System:
  OS: macOS 13.6.6
  CPU: (10) arm64 Apple M1 Max
  Memory: 55.52 MB / 32.00 GB
  Shell:
    version: "5.9"
    path: /bin/zsh
Binaries:
  Node:
    version: 20.14.0
    path: ~/.nvm/versions/node/v20.14.0/bin/node
  Yarn:
    version: 1.22.19
    path: ~/.nvm/versions/node/v20.14.0/bin/yarn
  npm:
    version: 10.7.0
    path: ~/.nvm/versions/node/v20.14.0/bin/npm
  Watchman:
    version: 2024.04.15.00
    path: /opt/homebrew/bin/watchman
Managers:
  CocoaPods:
    version: 1.15.2
    path: /opt/homebrew/bin/pod
SDKs:
  iOS SDK:
    Platforms:
      - DriverKit 23.2
      - iOS 17.2
      - macOS 14.2
      - tvOS 17.2
      - watchOS 10.2
  Android SDK: Not Found
IDEs:
  Android Studio: 2022.3 AI-223.8836.35.2231.10811636
  Xcode:
    version: 15.1/15C65
    path: /usr/bin/xcodebuild
Languages:
  Java:
    version: 11.0.22
    path: /usr/bin/javac
  Ruby:
    version: 2.7.7
    path: /Users/jamesholcomb/.rbenv/shims/ruby
npmPackages:
  "@react-native-community/cli": Not Found
  react:
    installed: 18.2.0
    wanted: 18.2.0
  react-native:
    installed: 0.72.7
    wanted: 0.72.7
  react-native-macos: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: false
iOS:
  hermesEnabled: true
  newArchEnabled: false 
gtokman commented 2 days ago

@jamesholcomb, thanks for the report. I wonder if the URLSession cache also needs to be cleared. I have some bandwidth to check this out & the onSuccess callback bug this weekend.