0

I have enabled caching of images

When i load the web page all the images are getting cached and are getting loaded from the cache with status 200 and status is from cache and size is 0

But all the images that are binded using knockout are not getting loaded from the cache and the status for those images are 304 - not modified and size is xxxkb

Below is the code i use

ko.applyBindingsToNode(element, {
                    attr: { src: renderImage(value) }
                });

in the render Image function i am attaching sharepoint rendering and returning the image url with the rendering id

It is used in other places as well, but they are getting cached

How can i force the browser to load the image from cache in this scenario?

Vignesh Subramanian
  • 7,161
  • 14
  • 87
  • 150
  • How do you know they're not loaded from the cache? Also, what makes you think it has something to do with Knockout? What if you emit regular HTML like ``? – haim770 Jun 11 '15 at 12:24
  • i checked in the network tab, and for all images except those that are binded using knockout, the status is 200 from cache, where as for knockout binded images status is 304 and size is xxxkb – Vignesh Subramanian Jun 11 '15 at 12:27
  • 1
    It will still be loaded from the cache in the 304 case, see http://stackoverflow.com/questions/1665082/http-status-code-200-cache-vs-status-code-304 – JohnnyHK Jun 11 '15 at 12:58

1 Answers1

0

I was facing same issue thought some bug in knockout.js src binding but at the end found each time src url get different due to encrypted id. Make sure your image url is same for caching in browser. otherwise it will not load from cache and will be loaded as new image server.

Usman Shah
  • 51
  • 2