Discussions

 View Only
Expand all | Collapse all

Thumbnail pictures refreshing slowly

Jump to Best Answer
  • 1.  Thumbnail pictures refreshing slowly

    Posted 04-26-2022 13:32
    My thumbnail pictures created with this:

    If(Length([Attachment File])=0,"","<img width=\"30\" src=\""&URLRoot()&"up/"&Dbid()&"/a/r"&[Attachment ID#]&"/e7/v0\"/>")

    refresh unbearably slowly. When I create a new record or create the first [Attachment File] in the record, there is no problem. Contrary to that if i edit a record already having an Attached file and i change the file to another, it takes more than minutes for the thumbnail image to refresh.
    Especially on a mobile device i need the thumbnails for the user to review the pictures taken in a report, so if an attachment file is changed, the report shall follow. But it - practically - doesn't.
    In my tests so far there are not more than 6 or 8 recoerd with thumbnails in a report, so i am not querying hundreds of them...

    Can I do anything to make the thumbnail refresh faster after edits? Am I creating the thumbnail picture the good way? Interested in any workaround if all else fails!

    Thank You!

    ------------------------------
    Laszlo M
    ------------------------------


  • 2.  RE: Thumbnail pictures refreshing slowly

    Posted 04-26-2022 14:16
    Edited by Simon H 04-26-2022 14:17
    The issue is with browser caching and not quickbase.
    The url that the formula generates is always the same per record, it is quickbase that dynamically serves up the latest version of the image at that url because it uses "v0"
    However the browser seeing the same url will load the image from the cache without even asking quickbase for the new image.

    You can test this on your end by reloading the record with a hard refresh by pressing ctrl-f5

    ------------------------------
    Simon H
    ------------------------------



  • 3.  RE: Thumbnail pictures refreshing slowly

    Posted 04-26-2022 14:29
    I did some more poking around.
    It seems like cache control is setting the cache time tp 2 minutes, so your assessment of "longer then a minute" is spot on. 
    A solution you can implement on your end is something to referred to as "cache busting"
    This is where you append a useless query parameter to the end of the URL so that the browser then sees is as a new url and requests the image anew without loading from the cache.
    I experimented with a formula that appends the last modified time to the url, however a simple update of the image does not actually set the last modified time so unless your users are also changing something else it won't work.


    ------------------------------
    Simon H
    ------------------------------



  • 4.  RE: Thumbnail pictures refreshing slowly

    Posted 04-26-2022 15:13
    Thank You Simon H for the interesting answers!

    On the desktop - I tried - hard refresh helps. Still it is a question for me how to initiate it from QB... if this is possible at all...
    But what can I do for my mobile users using the QB app on their devices? I have a form on my tablet before me with a thumbnail not refreshed for an hour or so...
    I feel on mobile - have to forget edited files' thumbnails.

    ------------------------------
    Laszlo M
    ------------------------------



  • 5.  RE: Thumbnail pictures refreshing slowly

    Posted 04-26-2022 17:02
    Edited by Simon H 04-26-2022 17:02
    Yeah, different devices/browsers can behave differently with regards to caching.

    What you can try on your end is to append a parameter at the end of the url in your formula. I tried using a a parameter based on the last modified time but that doesn't work if the only change to the record is the file attachment, as that doesn't seem to trigger an actual modification. If any other field are being changed then you cna try the formula below to see if it works

    If(Length([Attachment File])=0,"","<img width=\"30\" src=\""&URLRoot()&"up/"&Dbid()&"/a/r"&[Attachment ID#]&"/e7/v0?"& ToText([Date Modified])& "\"/>")

    ------------------------------
    Simon H
    ------------------------------



  • 6.  RE: Thumbnail pictures refreshing slowly

    Posted 04-26-2022 18:33
    I have a partial answer to avoid caching when the image file name has changed.

    The format we all use is this

    URLRoot() & "up/" & Dbid() & "/a/r" & [Record ID#] & "/e15/v0/

    but if you click an attachment it ill open up with this as the URL


    h t t p s://mycompany.quickbase.com/up/xxxxxx/g/rd/ei/va/Mark%20Ski%20Pix.jpeg

    I have a theory that
    the g is a constant
    The rd is r plus the Base32 Encode of the [Record ID#]
    The ei is e plus the Base32 encode of the field ID# of the file attachment
    the va is a constant
    The last part is the URLEncode of the file name.


    I will try that when I get a chance, maybe later tonight if i get my real work done first.

    If the file path changes then the image would not be cached.



    ------------------------------
    Mark Shnier (YQC)
    mark.shnier@gmail.com
    ------------------------------



  • 7.  RE: Thumbnail pictures refreshing slowly
    Best Answer

    Posted 04-26-2022 19:20
    OK, try this and see if it eliminates the caching issue. I was able to test this and change the file attachment and the "old" way stayed cached, but the new way immediately used the new image.

    "<img src=" & URLRoot() & "up/" & Dbid()
    & "/g/r" & QB32Encode([Record ID#])
    & "/e" & QB32Encode(12) // 12 is the fid of the file attachment field
    & "/va/" & URLEncode([Picture]) // my file field is called [picture]
    & " width=30>"

    ------------------------------
    Mark Shnier (YQC)
    mark.shnier@gmail.com
    ------------------------------



  • 8.  RE: Thumbnail pictures refreshing slowly

    Posted 04-27-2022 04:09
    Fabulous!
    Thank You very much Mark!

    László

    ------------------------------
    Laszlo M
    ------------------------------



  • 9.  RE: Thumbnail pictures refreshing slowly

    Posted 04-27-2022 11:22
    Mark,

    Did you finally solve the caching issue?! I will try this as well.....thanks!

    ------------------------------
    Mike Tamoush
    ------------------------------



  • 10.  RE: Thumbnail pictures refreshing slowly

    Posted 04-27-2022 11:27
    Yes, I believe I have successfully reverse engineered into the required syntax to access the image by file name name and not just by the current file in the field.  I'm recreating the same URL that you get when you click on the file attachment of the image and it opens up in the browser.

    ------------------------------
    Mark Shnier (YQC)
    mark.shnier@gmail.com
    ------------------------------



  • 11.  RE: Thumbnail pictures refreshing slowly

    Posted 04-27-2022 12:04
    Nice work on the URL breakdown.
    Although after playing around I realized that the actual filename makes no difference in the url, all you need is the part up until the "v"
    The "va" is actually "v" & QB32Encode("file revision number") and so 0 which always points to the latest version is "va". However you can leave all that out entirely and still get the latest version by default.

    Another thing i noticed is that if you use the option to restore a files previous version, that does not trigger a record edit or refresh, so the last modified timestamp will not update, and interestingly enough neither will the text value for the image file name.
    This could break Mark's formula as it relies on the correct file name file name changing.
    If however you edit the record to upload a new file the new name will be reflected and the date modified will update. In which case my solution posted above using a cache busting parameter, actually will work even if the file name stays the same

    ------------------------------
    Simon H
    ------------------------------



  • 12.  RE: Thumbnail pictures refreshing slowly

    Posted 04-27-2022 12:17
    If you go the cache busting parameter way, perhaps use totext(MSecond(ToTimeOfDay(Now())))

    instead of date modified? Would that work to always have a new parameter?

    I've fought with this issue for years so if one of these two solutions works that would be great.

    ------------------------------
    Mike Tamoush
    ------------------------------



  • 13.  RE: Thumbnail pictures refreshing slowly

    Posted 04-27-2022 12:31
    That would cause the URL to refresh on essentially every reload, ignoring the cache each time which is probably not what you want, but i do like your seconds method as it makes for a cleaner URL but by using date modified it will only update if the record changes.
    now in the off chance that a record was updated at a timestamp ending with the same milliseconds as last time it will result in the same url, but i think that is a small enough edge case for most users.

    If(Length([Attachment File])=0,"","<img width=\"30\" src=\""&URLRoot()&"up/"&Dbid()&"/a/r"&[Attachment ID#]&"/e7/v0?"& ToText(MSecond(ToTimeOfDay([Date Modified])))& "\"/>")



    ------------------------------
    Simon H
    ------------------------------



  • 14.  RE: Thumbnail pictures refreshing slowly

    Posted 04-27-2022 12:49
    In my experience adding a suffix like this

    & ToText(MSecond(ToTimeOfDay([Date Modified])))& "\"/>")

    .... had no effect to defeat the chaching.

    ------------------------------
    Mark Shnier (YQC)
    mark.shnier@gmail.com
    ------------------------------



  • 15.  RE: Thumbnail pictures refreshing slowly

    Posted 04-27-2022 13:15
    Edited by Simon H 04-27-2022 13:16
    Hmm, works for me, here's a screenshot


    Static Url formula is 
    If(Length([Image])=0,"","<img width=\"30\" src=\""&URLRoot()&"up/"&Dbid()&"/a/r"&[Record ID#]&"/e6/v0\"/>")

    Cache buster is
    If(Length([Image])=0,"","<img width=\"30\" src=\""&URLRoot()&"up/"&Dbid()&"/a/r"&[Record ID#]&"/e6/v0?"& ToText(MSecond(ToTimeOfDay([Date Modified])))& "\"/>")

    ------------------------------
    Simon H
    ------------------------------



  • 16.  RE: Thumbnail pictures refreshing slowly

    Posted 04-27-2022 16:47
    OK, thx for posting.  We seem to have two solutions now. Better than zero solutions.

    ------------------------------
    Mark Shnier (YQC)
    mark.shnier@gmail.com
    ------------------------------