Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[feature]: Cache only 1 version of HTML and return that for all routes. #1781

Closed
3 of 7 tasks
revanth0212 opened this issue Sep 25, 2019 · 2 comments · Fixed by #1874
Closed
3 of 7 tasks

[feature]: Cache only 1 version of HTML and return that for all routes. #1781

revanth0212 opened this issue Sep 25, 2019 · 2 comments · Fixed by #1874
Assignees
Labels
enhancement New feature or request performance Things related to perf

Comments

@revanth0212
Copy link
Contributor

Is your feature request related to a problem? Please describe.
Related to #1673

Describe the solution you'd like
As of today, all routes get the same HTML file even if the request originated as /, /search.html or /venia-tops.html or /valeria-two-layer-tank.html but with a different name. The problem arises when the user directly goes to a certain products page during the offline mode, whose HTML is not cached. Even though it is the same HTML since the route is different the browser will redirect to Network Unreachable error. This is because we give different names to routes that bear the same content and the service worker caches that HTML with the key as the route. We should change the HTML handler in service worker to save only 1 version of HTML and return it even if the request originated from a different route.

By not requesting HTML every time and utilizing a cached version till something changes we can save 855 Bytes of data over the network and also reduce our cache memory footprint.

out_temp

image

Please let us know what packages this feature is in regards to:

  • venia-concept
  • venia-ui
  • pwa-buildpack
  • peregrine
  • pwa-devdocs
  • upward-js
  • upward-spec
@revanth0212 revanth0212 added the enhancement New feature or request label Sep 25, 2019
@revanth0212 revanth0212 added the performance Things related to perf label Sep 30, 2019
@revanth0212
Copy link
Contributor Author

If the HTML changes in the future we can show a message like this

image

so the user can click and update the app.

This solution, I feel, might be annoying since customers who are shopping would not like to reload a page.

The second solution would be to use versioning API and request the current version of index.html and if:

  • that is same as what is in the cache return the cached HTML file
  • that is not same as what is in the cache, request new HTML file and update the cache

This was we won't be requesting 850 Bytes of data every time and also speed up the app load since it is served from cache, and if something changes we will only be wasting minimal amount of time.

@cherdman
Copy link
Contributor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request performance Things related to perf
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants