Exploring another path, I found that there is a method of the HTML5 Canvas toDataURL();
So I wrote this to download the image, instead of my XHR method :
Then this to handle the loaded image and cache it :
To keep things short I have excluded the DB sections, I always check if I have an image cached already before I fetch one, and always write it to the DB when I do fetch. If an image is retrieved from the DB it can simply be written to the img.src as is.