Closed pkarw closed 5 years ago
@NataliaTepluhina could You please reframe this issue's description and put it into docs as kind of "How Offline Mode works" ?
Any other ideas how to improve this - feel free to comment :)
Ill take it :)
@filrak it seems like @patzick already took it :) we discussed it yesterday evening and he’s already investigating this issue
Haha no problem. Just please consult it with me. We should obviously use Workbox for this
And take this into account https://github.com/DivanteLtd/vue-storefront/issues/1994
We need to consider this one as well: https://github.com/DivanteLtd/vue-storefront/issues/1698
What is the motivation for adding / enhancing this feature?
The indexedDB caching prooved to be a problematic solution because of:
This is PER-QUERY cache that we can replace with Service Worker cache. We can switch-off this logic in this PoC
IMPORTANT NOTE: Service Worker CAN NOT cache the POST requests - currently all the api/rest and graphql requests
We can easily modify the search adapter to send the GET requests + the searchQuery as a base64 encoded GET parameter instead of JSON body (check this) - and then modify the
vue-storefront-api
to unpack the GET-based search query and pass it to Elastic in correct format.However, we CAN NOT add service worker caching for graphQL queries (read on graphQL supprt)
So - this service-worker only caching strategy should be disabled automatically when the
search.engine=graphql
and use the current indexed-db based cache as there won't by any offline mode otherwise.The same in the situation when
service-worker
cache is not available at allproduct/quickSearchByQuery
There is no network call for product data as we're using the product data pre-fetched in the
product/list
actionThis cache won't be replaced by Service Worker. In fact - we probably need to keep this logic to avoid additional network-calls on product page (
product/single
vuex action) because of ...product/single
action)The question is - how to keep this "pre-fetching" enabled without using the indexedDB? I mean per-sku cache. Service worker cache will work on full queries (
product/list
results).Probably: we can store the per-sku cache (2) just in kind of in-memory hash - as the
product/list
action is always called first (as user is browsing first the category/search results - then selecting the product - so inproduct/list
we can populate the memory cache allowingproduct/single
to use it)Our indexedDb driver is using the in-memory stores for speed optimization already
Notes:
category
actionsstorage.ts
is used also for accessing localStorage - shopping carts, user tokens etc and probably it shouldn't be modified/api/*
requests are excluded from Service Worker -What are the acceptance criteria
search.engine = graphql
as graphQL is only available via POST and no service-worker caching is possible on these requestsCan you complete this feature request by yourself?
Additional information