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

F5 reload spends 2 requests available #14

Closed
pepetorres1998 opened this issue Dec 21, 2020 · 6 comments · Fixed by #28
Closed

F5 reload spends 2 requests available #14

pepetorres1998 opened this issue Dec 21, 2020 · 6 comments · Fixed by #28
Labels
enhancement New feature or request help wanted Extra attention is needed
Milestone

Comments

@pepetorres1998
Copy link

I don't know if it is the expected behaviour or a bug.

Before F5:
imagen

After F5:
imagen

@iksaku
Copy link
Owner

iksaku commented Dec 21, 2020

Sadly this is expected behavior at the moment.

Each time you load, reload or update the search parameters, one request is sent to GitHub’s API.

The best we could do is to only spend 1 request to fetch the repository list on load/reload, but due to the way that stats need to be fetched, we need to spend a second request initially.

I’m looking for a way to “cache” these stats at build time and keep them static for upcoming requests, this way, we could fire an update weekly and have decent update time, however, there’s no easy way ATM for this.

Will keep this open, I’m thinking on making the necessary changes for static first loads when Nuxt v3 is released.

Thanks for the heads up!

@iksaku
Copy link
Owner

iksaku commented Dec 21, 2020

Quick follow up... It seems that I misconfigured the project... I was hoping to provide a full static (target: 'static') page for initial load, however, the build is serving an SPA...

According to NuxtJS Docs, the ssr config flag prepares the project to be either rendered by a server or by the client entirely.

  • If set to false (current value), the project will be configured to render entirely by the client as a SPA, ignoring the target: 'static' configuration if not enforced by a plugin (Like a markdown renderer or something).
  • If set to true (going to set this), the project will be configured to render by a server.
    • If ssr: true and target: 'static', then the project will be completely rendered at build time, publishing pure HTML and CSS for static content, and injecting payload for dynamic content (smart!)
    • If ssr: true and target: 'server', then the project will be published as a runtime to execute using NodeJS on a server and render each page on the server whenever a request is received.

So, we are already expecting target: 'static', now the thing is to configure ssr: true and expect full static payloads 🎉.

@pepetorres1998
Copy link
Author

I was looking for something simple to contribute 😅 , do you have something on your mind?

@iksaku
Copy link
Owner

iksaku commented Dec 22, 2020

I have some ideas locally. If you’re free tonight we could spin up a simple pair programming session to further discuss what I got in mind.

PS: Here are my thoughts:

  • Extract main logic into hooks.
  • Make use of Nuxt’s Static helpers to generate data for first load.
  • Read static data from components and setup hooks once rendered on client.

@pepetorres1998
Copy link
Author

This week I have tons of pending job, what about next week? 😄

@iksaku
Copy link
Owner

iksaku commented Dec 22, 2020

Sure thing, I’ll keep trying out, maybe push tonight a new branch with experimental changes

@iksaku iksaku added enhancement New feature or request help wanted Extra attention is needed labels Dec 30, 2020
@iksaku iksaku added this to the v3.1 milestone Dec 30, 2020
@iksaku iksaku mentioned this issue Jan 13, 2021
6 tasks
@iksaku iksaku closed this as completed in #28 Feb 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 help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants