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

Optimize menu item, options, and cart queries #202

Open
2 tasks
AndrewLester opened this issue Aug 1, 2021 · 0 comments
Open
2 tasks

Optimize menu item, options, and cart queries #202

AndrewLester opened this issue Aug 1, 2021 · 0 comments
Labels
enhancement New feature or request
Milestone

Comments

@AndrewLester
Copy link
Member

AndrewLester commented Aug 1, 2021

Currently, both the menu page and the cart page make separate queries for the menu items, options, and the users cart. Two separate strategies could be implemented to decrease the number of queries made overall.

First, making requests for the menu items and options on both pages of the site is unnecessary in sveltekit's SPA structure. Instead, let's make a request for the menu items and options inside the __layout file of routes directory, which will only run once when the user loads either the cart or menu pages. When the user switches between the two, this file won't run.

To get the data from the __layout file into the actual pages (menu and cart), you can either use Svelte's context API or a store. I recommend a store in this case.

Second, reducing the number of queries for the user's cart may be a more elaborate problem. My idea was to use the fact that a query is made to add items to a user's cart from the menu page. We can respond to this with the user's cart data so that the following redirection to the cart page will already have the necessary cart data, and doesn't have to make another request for the user's cart. If the cart page is being viewed not following a cart item add, then then the cart data must be fetched. Passing data from the cart item add to the cart page can be done using a store.

@AndrewLester AndrewLester added the enhancement New feature or request label Aug 1, 2021
@AndrewLester AndrewLester added this to the Future milestone Aug 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant