Caching images with src and ng-src

3,382 views
Skip to first unread message

Jake Williams

unread,
Nov 27, 2013, 11:24:29 AM11/27/13
to ang...@googlegroups.com
So, we have a page that is displaying an image and another page that sets the image.  The image is saved on the filesystem as <some-location>/Default.png and is retrieved from the server when the user changes a default value on another page.

The current behavior is if the user has an image showing on the first page, and goes to the other page and changes what the image will be then comes back, the image will still be the old image on the page, even though if you look in the file system, Default.png is the new image and the old image no longer exists.  This happens with both src and ng-src.

We're open to the idea that this may be the webview since we're in a phonegap app, but I wanted to make sure there wasn't any image caching going on in angular.

Daniel Tabuenca

unread,
Nov 27, 2013, 11:54:50 AM11/27/13
to ang...@googlegroups.com

No, there’s no magic going on here. If you are using just src= angular is not involved at all. If you are using ng-src then angular is simply setting the src attribute. Any caching is done exclusively by the browser. You could force it not to cache by appending a random string to the end (e.g. src="myImage.png?124987812").

Reply all
Reply to author
Forward
0 new messages