Bug - WebDialogs are caching and not refreshing images
-
(Perhaps a known bug, but the first time I've hit it. Running SU Pro 7.1.5803 )
Loading several SU thumbnails (.png files) into an HTML table via the <img...> tag, SU refuses to load new or changed images once a file of a given name is used in a web dialog. You have to quit SU completely, not just close the model and reopen it (on a Mac), in order to obtain an updated copy of the image. Seems to me the browser used inside SU for the purposes of web dialogs has a pit bull hold on images in the image cache.
At first I thought SU was not updating the image for a component.definition.save_thumbnail or a refresh_thumbnail, but that all seems to be working fine, as the video shows.
I've attached a video demo of the bug.
-
You're seeing this on PC? Or Mac as well?
IE is known for aggressive caching.
If you press Ctrl+F5 (a force refresh) do the images reload then?When developing websites you can set the HTTP headers for files to tag them to never be cached. Not sure how to do that on local files. With HTML files you can set META tags I think - but not with images... Maybe if you set a no-cache tag in the HTML it'll affect the externally linked resources...?
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
- add to right after the HEAD opening tag. -
Or - maybe adding a fake URL query argument to the image URL:
<img src="myImage?randomNumber" />
-
@unknownuser said:
On the <img src='filename.png'> tag, by adding a random value after the filename, as you would do with a query string, forces the browser to reload the image. So, instead of 'filename.png', I use 'filename.png?123456789', where '123456789' (or whatever) gets appended and it is generated by the Javascript var seconds = new Date() ; function call.
That's what I meant by my last comment.
Good thing that works locally. I got something planned where I'd probably need to do this. -
Thanks Thomas - but the meta tag didn't work. I'm on a Mac - I have not started porting to Windows yet.
On a Mac, you reload a (non-WebDialog) web page via CMD+R. However, in a WebDialog, CMD+R activates the PAN tool in SU.
I had already stated that if a new file name was used, the new image would load, but I wasn't really interested in creating a new unique name each time, as the user's disk could get cluttered with obsolete thumbnails. (Are they mine to delete? Are they not? - I didn't want to go there.)
TBD had a suggestion to just delete the files when the WebDialog closed, and this might be a good solution too, but I found a trivial/benign solution over on StackOverflow that does the trick (aka, WORKAROUND). Here's the trick.
On the <img src='filename.png'> tag, by adding a random value after the filename, as you would do with a query string, forces the browser to reload the image. So, instead of 'filename.png', I use 'filename.png?123456789', where '123456789' (or whatever) gets appended and it is generated by the Javascript var seconds = new Date().getTime() ; function call.
Thanks - your first post keyed me into searching further for how to cause the browser to not cache images and I didn't even notice your second post - and what I found was exactly what you suggested!.
Todd
(edit - adjusted some comments )
-
I don't think it's an SU bug, it's probably a browser cache quirk.
I wonder if the image table was enclosed inside a FORM block, would the Js method
%(#BF00BF)[form.reset]
cause the images to refresh? -
@dan rathbun said:
I don't think it's an SU bug, it's probably a browser cache quirk.
I'll agree to call it "behavior" until we get (if ever) a control to influence what the embedded browser is doing and as long as the hack works.
@dan rathbun said:
I wonder if the image table was enclosed inside a FORM block, would the Js method
%(#BF00BF)[form.reset]
cause the images to refresh?Good idea. Try it and let us know.
Advertisement