Ahmet Ekrem SABAN
asked on
How to get the cached image of the browser?
Hello!
I am implementing a Web page in JavaScript with Angular.JS & ionic. A page generator is one of the menu items that has a header field where the user can load a file. With the [Save] button, the result is sent to the relational database.
The page generator is saving the whole generated HTML object in the database like
where the image is denoted with style="background-image: url("blob:null/3dfb1617-e1c8-4 5e8-9c0e-5 f772129d2c b");. This is probably the unique key of the cached browser object, is it? If so, I want to save this image as a BLOB object, say, in another field of the same database record.
Question: How is it possible to get this image out of the browser? Is there a difference getting out this information between different browsers?
Thank you for your reply!
I am implementing a Web page in JavaScript with Angular.JS & ionic. A page generator is one of the menu items that has a header field where the user can load a file. With the [Save] button, the result is sent to the relational database.
The page generator is saving the whole generated HTML object in the database like
<div class="hero-image" ivm-bg-axis="y" ivm-bg-drag="" ivm-bg-disabled="disabled" ng-style="imageOptions.style" ngf-background="ngModel" style="background-image: url("blob:null/3dfb1617-e1c8-45e8-9c0e-5f772129d2cb");"></div>
where the image is denoted with style="background-image: url("blob:null/3dfb1617-e1c8-4
Question: How is it possible to get this image out of the browser? Is there a difference getting out this information between different browsers?
Thank you for your reply!
ASKER
Thank you for your reply, David Favor! Can we say that all browsers will cache the image as long as it is visible? If so, it is enough caching for me, as I only need the displayed image for the database. Then, I have somehow to create a handle to the image next time I load the div element from the record & assign the image saved in another attribute of the same record to this URI to make it visible at a later time.
To save the image, what I need is in pseudo-code something like
To save the image, what I need is in pseudo-code something like
var cache = new BrowserCache();
var imageURL= cache.querySelector('url["blob:null/520cf0e0-fa19-438c-9db7-68af87f30f56"]');
var image = cache.getElement(imageURL);
// Convert image to appropriate format, if necessary
// Add image information to record to be sent to the server
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
This was the solution I found for this question.
Better to just generate images at server end + add some sort of cache busting tag, like foo-1.2.png + then increment the version number + reference the new version number in your HTML.
I do this with jquery, for example I know jquery-3.2.1.min.js will never change, so when an update occurs, each reference becomes query-3.2.2.min.js in my HTML.
This way I can set expires tags on this type of file for a far future date, like 10 years, so once it's in a person's browser cache, it's there forever + never loads of a server again.