{"id":13550849,"url":"https://github.com/nareddyt/traced_cache_manager","last_synced_at":"2025-05-03T10:31:10.298Z","repository":{"id":45292021,"uuid":"285740784","full_name":"nareddyt/traced_cache_manager","owner":"nareddyt","description":"Flutter CacheManager implementation that integrates with Firebase Performance Monitoring to automatically record traces for network requests.","archived":false,"fork":false,"pushed_at":"2021-12-23T20:19:24.000Z","size":126,"stargazers_count":4,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-05-03T08:52:17.645Z","etag":null,"topics":["cache","dart","firebase-performance","flutter","flutter-package","trace"],"latest_commit_sha":null,"homepage":"https://pub.dev/packages/traced_cache_manager","language":"Dart","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nareddyt.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-08-07T04:56:42.000Z","updated_at":"2023-11-22T08:19:54.000Z","dependencies_parsed_at":"2022-08-19T10:20:56.832Z","dependency_job_id":null,"html_url":"https://github.com/nareddyt/traced_cache_manager","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nareddyt%2Ftraced_cache_manager","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nareddyt%2Ftraced_cache_manager/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nareddyt%2Ftraced_cache_manager/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nareddyt%2Ftraced_cache_manager/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nareddyt","download_url":"https://codeload.github.com/nareddyt/traced_cache_manager/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252178685,"owners_count":21707039,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cache","dart","firebase-performance","flutter","flutter-package","trace"],"created_at":"2024-08-01T12:01:38.483Z","updated_at":"2025-05-03T10:31:09.975Z","avatar_url":"https://github.com/nareddyt.png","language":"Dart","funding_links":[],"categories":["Dart"],"sub_categories":[],"readme":"# traced\\_cache\\_manager\n\n[Cache Manager](https://pub.dev/packages/flutter_cache_manager) implementation that integrates with \n[Firebase Performance Monitoring](https://firebase.google.com/docs/perf-mon) to automatically \nrecord traces for network requests.\n\n![](doc/firebase_perf_console_trace.png \"Firebase Performance Console with a automatically collected network trace\")\n\n## Background\n\nThe Firebase Performance [flutter plugin](https://pub.dev/packages/firebase_performance) allows\nyour app to record traces for network requests and publishes them to \n[Firebase Performance Monitoring](https://firebase.google.com/docs/perf-mon). \nHowever, the plugin does not automatically collect traces for **all** network requests your app makes.\n\nOne popular unsupported widget is [`cached_network_image`](https://pub.dev/packages/cached_network_image),\na flutter library to show images from the internet and keep them in the cache directory. Under the hood,\nthis widget uses [`flutter_cache_manager`](https://pub.dev/packages/flutter_cache_manager) to \ndownload and cache files in the cache directory of the app. When a cache miss occurs, the network\nrequest to download the file is not automatically traced with Firebase Performance flutter plugin.\n\nThis package (`traced_cache_manager`) provides a custom Cache Manager implementation that automatically\ntraces network requests and publishes them to Firebase Performance Monitoring. It can be used with\n[`cached_network_image`](https://pub.dev/packages/cached_network_image) to automatically trace network\nrequests when downloading images from the internet.\n\n## Setup\n\n1. Add the Firebase Performance [flutter plugin](https://pub.dev/packages/firebase_performance) to your app.\nFollow the setup instructions in that package to integrate with Firebase Performance Monitoring.\n2. [Install](https://pub.dev/packages/traced_cache_manager/install) this package.\n\n## Usage\n\nThere are 3 use cases for this custom cache implementation.\n\n### With cached\\_network\\_image\n\nAutomatically trace all network requests made by the `CachedNetworkImage` widget.\n\n```flutter\nCachedNetworkImage(\n  imageUrl: 'https://picsum.photos/500',\n  ...\n  cacheManager: TracedCacheManager(),\n)\n```\n\n### As a general file cache\n\nAutomatically trace all network requests made when fetching files for the cache.\n\n```flutter\nFuture\u003cFile\u003e fetchFile(String uri) async {\n  return await TracedCacheManager().getSingleFile(uri);\n}\n```\n\n### In a custom Cache Manager implementation\n\nIf you are writing a custom cache implementation and want automatic tracing of network requests,\nyou can use `TracedHttpFileService` as an argument to the `BaseCacheManager`.\n\n```flutter\nclass MyCustomCacheManager extends BaseCacheManager {\n  ...\n  MyCustomCacheManager({...}) : super(key, fileService: TracedHttpFileService(), ...);\n}\n```\n\n## Troubleshooting\n\nIf you have an issue with this library, file an [issue](https://github.com/nareddyt/traced_cache_manager/issues).\n\nIf you do not see traces in the Firebase Console, reference the official Firebase\n[Troubleshooting Guide](https://firebase.google.com/docs/perf-mon/troubleshooting?platform=android).\nNote that it may take 24-48 hours for network traces to show up.\n\nConsider clearing your application's cache to force network requests on a cache miss.\n- [Android example](https://www.androidcentral.com/how-and-when-clear-app-cache-or-data-android).\n- [iOS example](https://www.macrumors.com/how-to/clear-cache-iphone-ipad/).\n\n## Contributing and Support\n\nPull requests are welcome.\nFor major changes, please open an issue first to discuss what you would like to change.\n\n## License\n\n[MIT](https://choosealicense.com/licenses/mit/)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnareddyt%2Ftraced_cache_manager","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnareddyt%2Ftraced_cache_manager","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnareddyt%2Ftraced_cache_manager/lists"}