Currently, in CacheManager._pushFileToStream when a cacheFile exists, the cached content is emitted, and if it is outdated, a network request is made to potentially update the file, and emit the updated content.
If a 404 happens on that request, the error is not added to the stream, and the cache is not evicted.
The error is only added if no cacheFile exists.
Expected behavior
On the 404, the cache is evicted (the server is telling us the resource no longer exists) and the error is added to the stream.
🐛 Bug Report
Moving https://github.com/Baseflow/flutter_cached_network_image/issues/898 to here.
https://github.com/Baseflow/flutter_cache_manager/blob/32b71c1da1689b97434959ac407b03b74d7e405c/flutter_cache_manager/lib/src/cache_manager.dart#L137-L157
Currently, in
CacheManager._pushFileToStream
when acacheFile
exists, the cached content is emitted, and if it is outdated, a network request is made to potentially update the file, and emit the updated content.If a
404
happens on that request, the error is not added to the stream, and the cache is not evicted.The error is only added if no
cacheFile
exists.Expected behavior
On the
404
, the cache is evicted (the server is telling us the resource no longer exists) and the error is added to the stream.Reproduction steps
See https://github.com/Baseflow/flutter_cached_network_image/issues/898
Configuration
Version: 3.1.1
Platform: Tested on macos but should affect all platforms