Maybe it’s something in UI, but many times I watch pictures (not even videos, they are their own can of worms), and want to save them, it shows me that I’m downloading them again although they are cached in whatever app I see them from.

Like this link with a happy dog: https://i.pinimg.com/736x/71/1e/52/711e52f1d6c7ead78f4380214f68c259.jpg

I see it in high rez in my browser, I can zoom in, and I can’t tell any difference from a copy that I can download, but it’s still, well, another download if I want to save it, and not a move from cache to my download folder, another request to the server, another waste of traffic.

Is there some rule of sandboxing for everything you load that I don’t know about? In cases like our fediverse, I wouldn’t like to cause double load when I already have the picture I want. Can I cut it down with some plugin in mobile Firefox?

I feel like I’m missing something big time.

  • zoostation@lemmy.world
    link
    fedilink
    arrow-up
    15
    ·
    16 hours ago

    It’s simpler code to re-download the file than retrieve what cached version may or may not exist in memory or on disk. Developers often like to keep code simple at the expense of some kinds of efficiency, like this.

    An image is usually small enough to be downloaded in no time on a fast connection, which is what developers usually have and don’t stop to think that others might not have.

    A video is probably being streamed so earlier segments may no longer be present locally.

    • FourPacketsOfPeanuts@lemmy.world
      link
      fedilink
      arrow-up
      1
      ·
      edit-2
      29 minutes ago

      It’s simpler code to re-download the file than retrieve what cached version may or may not exist in memory

      This seems incredible

      There would already have to be a data layer that serves the main web page renderer. That layer would already have to handle looking in the cache or making an http request in event of a cache miss. It would seem almost trivial for a UI operation like ‘save to disk’ to simply call that layer to obtain the data if it’s available locally else make the http request it was going to make anyway…

      For a few hundred K image file I can understand why some might not bother, but I’ve seen this behaviour where a browser already has an MP4 cached (such that it can replay any part of it without subsequent http traffic) and yet it still makes a new request when saving. It’s weird to be honest…

    • gazby@lemmy.dbzer0.com
      link
      fedilink
      arrow-up
      11
      ·
      16 hours ago

      If it were difficult or time consuming to lookup or fetch items from the cache, it’s not a very effective cache 😬

      • zoostation@lemmy.world
        link
        fedilink
        arrow-up
        6
        ·
        edit-2
        15 hours ago

        It’s more about keeping the downloads code independent from the cache code. Once one depends on the other, you can’t change either one without considering the other. Minimizing dependencies is a way of reducing complexity.

      • snooggums@lemmy.world
        link
        fedilink
        English
        arrow-up
        3
        ·
        16 hours ago

        Easy for the browser to lookup and fetch, not necessarily the process of writing permanently to the disk.

          • snooggums@lemmy.world
            link
            fedilink
            English
            arrow-up
            3
            ·
            15 hours ago

            If the system isn’t built to move it from memory to the disk then it isn’t easy to just move it over. The browser might have the file stored in a way that makes it easy to stop and fastforward or even allow it to play or partially load,. Trying to save a file that might be incomplete is far more complicated than a good old reliable direct download.

            Think of it like orange juice. The browser may have stored it in a wide shallow bowl because that works better for the browser, but it would be a pain in the ass to pour into a small cup. Much easier to just pour a new cup of orange juice when it is in an expected format.

    • undefined@lemmy.hogru.ch
      link
      fedilink
      arrow-up
      2
      ·
      edit-2
      16 hours ago

      Maybe I’m not understanding the question but typically a CDN will have HTTP headers to signal to the browser to cache the asset (image). I can’t imagine Pinterest isn’t using a CDN (with said headers), so if it’s re-fetched over the network that sounds like a browser problem more than a developer one.

      • zoostation@lemmy.world
        link
        fedilink
        arrow-up
        4
        ·
        16 hours ago

        That’s right, I was referring to the browser/client developer. The browser cache is treated as ephemeral storage so it’s not a safe assumption that a previously downloaded file is still there.

        • undefined@lemmy.hogru.ch
          link
          fedilink
          arrow-up
          1
          ·
          edit-2
          15 hours ago

          That’s crazy. I love Safari (I know, it sucks and I’m in the minority) and it usually caches things in memory and doesn’t redownload. Have I been in Appleland too long?

          I’m a web developer and deal mostly with complex backend stuff, but is this issue of browsers not caching content common? This is news to me.

          Edit: Omg never mind, I did misunderstand the question. It’s when saving it that it redownloads and yeah, I’ve totally noticed it too.

  • adarza@lemmy.ca
    link
    fedilink
    English
    arrow-up
    7
    ·
    edit-2
    15 hours ago

    a straight, ordinary image display in a page or tab will save to the cache, and if you then save it to disk yourself from there, firefox will utilise the cache. i see this behaviour every day on pc.

    some addons will interfere with this. and cache settings, of course, do as well. there’s also some ways to construct a web page that makes it harder to save an image, or doesn’t save the image to the client’s cache at all–requiring another hit to and download from the origin to do the requested ‘save’

  • BrundleFly2077@sh.itjust.works
    link
    fedilink
    arrow-up
    2
    ·
    12 hours ago

    I notice this with pdfs. I view a pdf in browser and then when I want to download it the damn thing has to come down again.

    For what it’s worth, I recently swapped to Linux and discovered this doesn’t seem to happen there.

    • miss phant
      link
      fedilink
      arrow-up
      3
      ·
      11 hours ago

      Yeah I can’t remember this behaviour either with Firefox on Linux. In fact when I save a half-loaded image to disk it will literally save just half the image.

    • Ephera@lemmy.ml
      link
      fedilink
      English
      arrow-up
      2
      ·
      12 hours ago

      Yeah, sometimes I even then can’t download the picture, even though I was looking at it just then, because the server can apparently tell the difference and returns an error code instead.