K
K
Konstantin B.2018-03-22 09:28:58
Frontend
Konstantin B., 2018-03-22 09:28:58

How to save the list of items so that they do not reload on each transition back to Vue?

I started writing on Vue, in general, everything is going well, but there was one unpleasant moment.
I have a list of valid products that I receive from the server via axios, when I go from this list to the product, and then when I click back, the request to get the list again goes to the server, this is the question, how can I reuse the one already received list?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
L
Lumore, 2018-03-22
@Kostik_1993

Use Vuex

E
eRKa, 2018-03-22
@kttotto

You can cache the request by setting the ajax request parameter cache=true.
You can use the internal storage, remember the first answer, the next ones give it away. But in this case, you need to make a button for the "update" list.

K
Klein Maximus, 2018-03-26
@kleinmaximus

You can, for example, cache the results after the first request in LocalStorage, and on subsequent connections of the component, check for the presence of saved data. But still, we need a mechanism for clearing the cache by time or by user action.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question