Do we need to manually delete the recorded cached video file using ImagePicker flutter plugin?

214

How long will the files remain in the cache folder?

Usually, cached files remains in the folder until you uninstall the application or when you use a "Clear Cache" option (also works with "File Cleaner" applications). In the case of images fetched from a web API they might contains a Cache-Control header which will help to define directives to invalidate them from the cache.

clear cache

Sometimes, a different behavior can occur on Android phones depending of the software overlay, for example Honor software (EMUI) is known for clearing cached files by itself from time to time, but it does not seem like the exact duration is mentioned anywhere.

Does the Android/iOS system has some limitations on the size of the cache folder?

The cache folder does not have a size limitation, it will grow as big as needed (or until your phone runs out of available space), this is why people tends to recommend clearing the cache of certain applications manually when it becomes too big.

Share:
214
Manas
Author by

Manas

Updated on January 04, 2023

Comments

  • Manas
    Manas over 1 year

    I am using the ImagePicker (https://pub.dev/packages/image_picker) plugin to record videos and I noticed the recorded videos are stored in app's cache folder (example: /data/user/0/com.example.app/cache/999b6a18-114b-4fd3-b089-09ce4574bf765726458033916036262.mp4")

    In the plugin docs it says

    Note: Images and videos picked using the camera are saved to your application's local cache, and should therefore be expected to only be around temporarily. If you require your picked image to be stored permanently, it is your responsibility to move it to a more permanent location.

    Here's what I am wondering about:

    1. How long will the files remain in the cache folder? (I am concerned on too many video files being accumulated)
    2. What is the mechanism on the cache data? does the Android/IOs system has some limitations on the size of the cache folder?
    3. If there is some sort of limitations, what will happen if users record more videos will the system delete the older videos to make room?

    Overall would you guys recommend that I delete the recorded cached video immediately after processing it (Example uploading it to my server)?

  • Manas
    Manas almost 2 years
    thank you! that was very helpful in understanding the caching mechanism :) so in my case of video uploading, I would conclude that it is better to clean up the cached files if it serves no actual purpose after uploading it to the servers. Rather than leaving it to accumulate in the local storage or leaving it to be handled by the operating system