How to Cache Image Files with Ionic & Capacitor

แชร์
ฝัง
  • เผยแพร่เมื่อ 8 ก.ย. 2024

ความคิดเห็น • 43

  • @TheSaceone
    @TheSaceone 3 ปีที่แล้ว +2

    Wow! It actually was easier than I expected! Thank you Simon! As you say, you can store some time-to-live in order to know when to fetch an image again. But if you want to force it from your backend (for example, if you update one image and you want your users to have the updated version) in my opinion a good approach would be serving a version number along with the image url, and let the chached-img component refresh the image only in case its cached version number is less than the fetched version number. Just in case someone finds useful this backend-controlled-cached-time-to-live 😂😂😂🙌

    • @galaxies_dev
      @galaxies_dev  3 ปีที่แล้ว

      Yeah that would be a more advanced (and complicated) process I guess but definitely possible!

  • @slobodanmarkovic1983
    @slobodanmarkovic1983 3 ปีที่แล้ว +2

    Very, very useful. I'm going to use this tutorial to cache images in my app. Thanks.

  • @marcelvarela9058
    @marcelvarela9058 3 ปีที่แล้ว +6

    I just found out that instead of creating the missing folder in app.component, we can just set 'recursive: true' in the writeFile options. As shown in the documentation.

  • @IsraelSistemas
    @IsraelSistemas 3 ปีที่แล้ว +2

    Very useful and I'm waiting another video about review of ionic apps, I really enjoy those videos haha.

  • @upendramb7456
    @upendramb7456 3 ปีที่แล้ว +2

    Can you do a video on deployment to actual devices for android and ios

  • @guigoslima
    @guigoslima 3 ปีที่แล้ว

    Perfect, Simon! u are, the best!

  • @vincenzodamico3054
    @vincenzodamico3054 3 ปีที่แล้ว

    Hi Simon,
    first of all i have to told you just one thing: "THANK YOU SO MUCH!!!!"
    I love all your video, and tanks to you i grow myself in ionic developing.
    Can i ask you a favor, can you make a video with the implementation of paypal payment in ionic application if exist?
    thank you a lot.
    VD

    • @galaxies_dev
      @galaxies_dev  3 ปีที่แล้ว +1

      You are welcome Enzo! And yea, something with Paypal sounds interesting, I'll look into that!

  • @m_andrasch
    @m_andrasch 2 ปีที่แล้ว

    Hey, thanks so much for the insightful video! Just as optional side note: While getting started with Ionic/Capacitor + Angular PWA I wondered if I could also use Cache.put() Web Api instead of using ionic/storage? In theory this should work as well on all platforms then as well? 🤔Guess I have to try... 😎

    • @galaxies_dev
      @galaxies_dev  2 ปีที่แล้ว +1

      Actually haven't used that API but think it should work - cool idea indeed!

  • @blakebedford-palmer6676
    @blakebedford-palmer6676 3 ปีที่แล้ว +1

    Regular browsers eg Chrome like you're using here should cache the images automatically, but you have disabled cache in the network tab
    But does the capacitor webviews in iOS and Android have no cache? And that's why you have to add it manually?

    • @galaxies_dev
      @galaxies_dev  3 ปีที่แล้ว

      Afaik it will usually try to load images again when possible, so keeping them locally with this approach makes sure you don't send out more network requests then necessary!

    • @vulcanjibe
      @vulcanjibe ปีที่แล้ว +1

      @@galaxies_dev I don't understand too why you don't just trust the browser cache... it seems dangerous to cache images on local storage without max-age parameter for example... Thanks a lot for your worek, you are my MASTER!!!!

  • @arleonzemtsop3421
    @arleonzemtsop3421 2 ปีที่แล้ว

    Thank you very much for this tutorial 🙏. However I had a problem during the implementation. Everything works perfectly on the browser but on my mobile device the convertBlobToBase64 function is not executed and there is no error. I'm confused can you help me please 🙏🙏.

    • @galaxies_dev
      @galaxies_dev  2 ปีที่แล้ว

      Hmm any error logs why it's not executed?

  • @tranquillityEnthusiast
    @tranquillityEnthusiast 3 ปีที่แล้ว

    Hi Simon, I have issue of user experience with ionic, I want ionic to have good UI as React native has..

  • @minute_illimitee
    @minute_illimitee ปีที่แล้ว

    Hello Symon, is this demo available on github?

  • @ChristianWarnecke
    @ChristianWarnecke 3 ปีที่แล้ว

    With this approach one would loose the lazy load advantage of ion-image. This is quite good seen when your cache was clear, some images down the list where already loaded but none from the top. How would you combine image caching with lazy loading, without reinventing ion-img?
    How does this approach compare against caching with service workers? Are there any disadvantages with using service workers for this task? I think they could work maybe quite well with ion-img.

    • @galaxies_dev
      @galaxies_dev  3 ปีที่แล้ว +1

      The SW approach would only work on the web or PWA, not inside a native app (afaik). And I guess you would have to kinda reinvent it or check out the source code of ion-img, probably it's not too hard to implement at the end of the day!

    • @caiosantanna7070
      @caiosantanna7070 7 หลายเดือนก่อน

      Hey, try make a pipe that returns a observable.

  • @OwaisNadeem-hj5gk
    @OwaisNadeem-hj5gk 4 หลายเดือนก่อน

    This is working fine in android but getting filesystem plugin not implemented on ios

  • @lebonnanex
    @lebonnanex 3 ปีที่แล้ว

    Thanks Simon, great tutorial :) Is image caching needed when getting images from Firebase storage ?

    • @galaxies_dev
      @galaxies_dev  3 ปีที่แล้ว

      It's never necessary, always optional to improve your performance!

  • @EduardoLopezAmaya
    @EduardoLopezAmaya 2 ปีที่แล้ว

    First of all thanks for the video it works!
    But the performance of this method is pretty bad, especially noticeable with low-end phones and a lot of images. Any tip on how to improve this?
    Images are already compressed.

    • @galaxies_dev
      @galaxies_dev  2 ปีที่แล้ว +1

      Besides reducing the size of images I guess there is not much you can do!

    • @EduardoLopezAmaya
      @EduardoLopezAmaya 2 ปีที่แล้ว

      @@galaxies_dev I was wondering if adding the src directly from fileGetURI would improve performance. Wanted to test it but the method returns a URI that is not usable for anything. It is in the form of [directory]/[filename]
      Do you know how I can fix it to get a full URI I can use as src?

  • @farbod6450
    @farbod6450 3 ปีที่แล้ว +1

    I'm a bit confused. Can I use these codes for ios and android by capacitor?

    • @galaxies_dev
      @galaxies_dev  3 ปีที่แล้ว

      Sure you can with Capacitor!

    • @Nelsonmui87
      @Nelsonmui87 3 ปีที่แล้ว +4

      ​@@galaxies_dev This video is great.
      Does anyone having issue on android / ios device? It stop at reader.readAsDataURL(blob) function.

  • @minute_illimitee
    @minute_illimitee ปีที่แล้ว

    I am looking to reproduce this method exclusively on angular, is it possible?

    • @galaxies_dev
      @galaxies_dev  ปีที่แล้ว

      You could simply use localstorage or indexedDB!

    • @minute_illimitee
      @minute_illimitee ปีที่แล้ว

      @@galaxies_dev thank you for your answer, I watch your video less than 50 times, we love you

  • @antoinecandy
    @antoinecandy 3 ปีที่แล้ว

    Great tutorial ! But not working for pwa in iOS and Android browsers :'(

    • @galaxies_dev
      @galaxies_dev  3 ปีที่แล้ว +1

      Actually the Filesystem plugin should work fine in a PWA as well - why isn't it working for you?

    • @antoinecandy
      @antoinecandy 3 ปีที่แล้ว

      Dear​@@galaxies_dev , I just find out why ! It was because I mixed content : the pwa was running on https and I tried to access pictures with http url ! :)

  • @Nelsonmui87
    @Nelsonmui87 3 ปีที่แล้ว

    Hi, Does anyone having issue on Android / iOS device?
    It stop at reader.readAsDataURL(blob) function and without any error.

    • @daano98
      @daano98 3 ปีที่แล้ว

      I have the same issue, did you find a solution?

  • @ricko13
    @ricko13 3 ปีที่แล้ว +1

    idk

  • @ryananto7015
    @ryananto7015 3 ปีที่แล้ว

    Request plugin fake gps on capacitor... Thx

  • @tranquillityEnthusiast
    @tranquillityEnthusiast 3 ปีที่แล้ว

    I want ionic to be like react native..