Codechef4u is a community for computer professionals,by computer professionals,just like you; who loves sharing and helping each others,Join them
Share your post

IE 11 and edge fails to display latest updated images

Issue/bug title: IE 11 and edge fails to display latest updated images (it displays image from cache in case of same image name) but chrome perfectly display updated image.

In detail:

Hi team I found browser specific issue with image cache and image rendering with IE 11 and edge (not able to refresh updated image) but it works perfectly with chrome browser.

Technical problem (We tried with asp.net web form and asp.net MVC projects)

Sharing Web from sample code:

With asp.net web form page we are updating image URL dynamically, the following code return updated image for specific user (same name for image url) and assign image URL dynamically.

   protected void Page_Load(object sender, EventArgs e)
    {
          var imageDynamicUrl = ImageBuilder.GetProfileIamgeByUserName
(Security.CurrentMembershipUser.UserName);
         //updating image url dynamically
          imgProfile.ImageUrl = imageDynamicUrl;
    }

 

Browser URL for html image tag:

1. Old image url(for user abc)

       http://xyz.com/images /200wide/uaserProfile9.JPG (50kb)

2. Latest replaced image url (for user abc)

     http://xyz.com/images /200wide/uaserProfile9.JPG(78kb)

Chrome browser showing updated image “uaserProfile9.JPG(78kb)” , with same code bit IE 11 and edge browser showing old image (from cache).

IE and edge showing latest image only when we refresh page or delete history (cache) and refresh page.

Answers


Try following code tricks IE 11 and edge will show updated image perfectly,

C# code:

Added latest date time in last as query string so IE and edge browser able to understand which image is latest.

imgProfile.ImageUrl= imageDynamicUrl+ "?" + DateTime.Now.ToString(CultureInfo.InvariantCulture);

Image URL after fix:

Old URL:

http://xyz.com /images /200wide/uaserProfile9.JPG?03/21/2018%2012:30:02

Latest URL:

http://xyz.com /images /200wide/uaserProfile9.JPG?03/21/2018 12:31:15

Summery:

chrome browser is able to understand latest updated image (i.e. if image size/dimensions/content changed and updated with same name)  but IE and edge is not able to understand latest image, we require additional custom fix for ie 11 and edge, hope edge team will fix this issue.

Share your answer


Share as a guest

Please subscribe me to the CodeChef4U.

By creating your new answer, you agree to the privacy policy and terms of service.