Skip to content
This repository has been archived by the owner on Nov 16, 2021. It is now read-only.

Store SVG file in localStorage, then fetch and use it using with [inLineSVG]="" #86

Open
cyphercodes96 opened this issue Jul 23, 2018 · 5 comments

Comments

@cyphercodes96
Copy link

The title says it all.

I am currently using the following code to load my SVG Images from the assets folder inside my project directory.
[inlineSVG]="'/assets/Compression/' + position + '.svg'"

After loading my images for the first time, i need to push them into an array and save them to localStorage

Now my question, how can i load them back using that array that'll be fetched back from the localStorage?

@cyphercodes96
Copy link
Author

@arkon or if there is someway we can persist current cache feature to more then just a session lifetime, that would be awesome!

@arkon
Copy link
Owner

arkon commented Jan 17, 2019

I still need to think about this but why aren't you setting the cache control on the SVG assets instead? The browser can handle that perfectly fine without any of this manual caching logic.

@cyphercodes96
Copy link
Author

I still need to think about this but why aren't you setting the cache control on the SVG assets instead? The browser can handle that perfectly fine without any of this manual caching logic.

Could you elaborate more on what you meant by setting the cache control on the SVG assets instead?

@arkon
Copy link
Owner

arkon commented Jan 17, 2019

@cyphercodes96
Copy link
Author

I followed up with the docs, did some initial implementations using nginx as the server.

I added the headers Cache-Control: public and now i see a max-age header on each and every SVG request.

However, when I cache the SVG images using [cacheSVG]="true", on a session base, the load up quickly and in a really fast way.
However, now after setting the cache control on the SVG assets, monitoring the network tab in dev tools, I find out that at first, the SVG images are taking around 600ms to be loaded, EACH, and after the load, the 600ms load time is changed back to 5ms
Somehow, the inlineSVG is loading up the svg images on a normal basis, even if the cache exists, and after that, it's somehow rendering the cached images.
I still notice very slow load time, approximately 18 seconds for my component to load up, having 52 SVG's, each SVG is around ~ 180KBS, a few are ~500KBS

Any extra thoughts you share to help me out here? :/

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants