ACEG
ACEG

Reputation: 2041

Caching dynamically-generated images in front-end

I am currently working with the following situation: I have an Ember front-end with N entities, and the user can view dynamically-generated chart images for each of these entities. For this purpose, when the user wants to view the chart for on an entity, the following happens:

  1. the front-end sends a request for generating a chart image to a back-end endpoint
  2. this image is then passed to the front-end in the endpoint's response, as a base64 encoded image
  3. the front-end displays this image
  4. now, the user can select a new entity, etc.

At the moment, the user has to wait for a chart image to be loaded 3-5 seconds, no matter whether this entity's chart has been viewed before. This is quite annoying: wait to view chart for entity A, then wait to view chart for entity B, then wait again if you want to see entity A again, etc.

I want to cache somehow the already viewed images in the front-end, in order to avoid this waiting time. (The content of the images does not change frequently, perhaps once a day or so, so this is not a problem).

Can this be done with Ember, or am I looking at this from a wrong point of view and an entirely different strategy is required?

Upvotes: 0

Views: 146

Answers (1)

renno
renno

Reputation: 2827

Use .peekRecord() first and check if it has any result. If it's on the ember store, it will show to you. You can visualize if you are caching correctly on Ember inspector.

Upvotes: 1

Related Questions