Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Force the refresh of an Img

    I use a Img() object to render an image. Then, using a servlet, I modify the image on the server.

    Then I want to reload the image, force a redraw with the new version on the server. How to by-pass the caching from browsers?


    I tried this:
    Code:
    myImg.resetSrc();
    but to no avail.

    NB: The servlet currently does not return the modified image, but an succes message, upon which I want to redownload the image. Should the server 'stream' the image back directly? If so, how to incorporate something like this in the DSRequest/DSResponse flow?

    #2
    To force a reload (for a servlet that's actually returning image data) add a parameter to the URL that changes every time.

    But note that image download is built-in (viewFile/downloadFile APIs on DataSource - also getFileURL() API , recently added).

    Comment


      #3
      Okay, but the image is not bound to a dataSource. What is then the best approach? My thoughts would be:

      1) somehow make sure it IS databound (ie. a field in a .ds.xml file)
      2) create a different servlet, that directly streams the image, changing the URL slightly all the time.
      3) ... ?

      Comment


        #4
        I fixed it, thanks for the info

        Comment


          #5
          Can you decribe, how you have fixed it??

          I would like also to refresh an image after changes on server....

          Comment


            #6
            I actually removed the Img object and added it again, and I made sure the filename was different. I found that only using a src="img.png?randomnumber123" did not work in all browsers.

            So instead i gave the file a random filename each time it was changed.

            Comment

            Working...
            X