0

My current issue is that I have a loading bar animation on my web-based app that is shown (obviously) when the whole page or specific things are loading up. It is supposed to look like one of those Samsung TV Apps so it needs to be quite polished with the UX.

What me and my team are doing right now is a mix between creating an element for it and I assumed it gets cached in the local device which is an issue. I've known of a few ways that I can go around this like adding a Math.random() query at the end of the src url but I'd rather not follow that route for now.

I also saw a way that I believe involved simply setting the element.src = 'theSameUrl.gif' URL to be the same and I assume forcing the device to reload the file instead of using the cached one.

I would also be open to trying new file types that could make this a lot easier but I must keep in mind that this app will work on a LOT of different hardware, from Samsung TV's to BT Boxes or even Virgin Media Tv Boxes, amazon firestick etc.

At this point I'll take anything :P

  • Look [here](https://stackoverflow.com/questions/40498474/play-gif-image-in-html-with-infinite-loop#:~:text=Looping%20is%20encoded%20into%20the,the%20src%20is%20a%20video.). I hope it helps you. – Leo Jun 25 '20 at 16:55
  • Unfortunately that is not what I was looking for, the gif is already looping. What I want is that it restarts when it is visible ALL times – Miguel Vieira Jun 29 '20 at 09:39

1 Answers1

0
  1. You can "force it" to reload by wiping it source: img.src = ""
  2. Then you set it again: img.src = "your_src_path"

This way your .gif will start from zero, at least on Edge, Chrome and Firefox, it should work the same way on a TV.

Leo
  • 849
  • 7
  • 20
  • 1
    Ah I see that seems to be the only possibility. Do you know if this reloads it from cache or re-downloads it? – Miguel Vieira Jun 30 '20 at 11:05
  • It reloads from cache. In this case, HTTP response status should be `304 Not Modified`. Even total network transferred data (Bytes) does not increase when you get that response status. – Leo Jun 30 '20 at 12:26
  • Nice, sick man thanks this was extremely helpful. My team decided not to go ahead with restarting the gif as it took too much time already and the project has some redundancies for this. But I will keep this in mind for the future cheers! – Miguel Vieira Jul 01 '20 at 13:20