-
Notifications
You must be signed in to change notification settings - Fork 3
Server rendering for homepage, units and topics listing pages #1847
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
Conversation
Merge branch 'main' into jk/5919-prefetch-mechanism
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
Comment: I think we should do...something... with frontends/main/src/app/getQueryClient.ts
. It talks about its behavior for SSR, but is not used for SSR.
Do you know if the query client config matters when query client is used on server?
I don't think so given they're configuring cache behavior and retry etc, whereas on the server our query client is throwaway at the point we dehydrate for each request. It would be useful though to have a server side query client singleton that is scoped to the request. Next.js doesn't seem to have any way to access the request object outside of the middleware file to code for the request/response lifecycle. |
* Warn on API calls during initial render not prefetched * Full prefetch for homepage (commented) * Prefetch utility * Check for queries prefetched that are not needed during render and warn * No need to stringify * Replace useQuery overrides with decoupled cache check (wip) * Observer count for unnecessary prefetch warnings * Remove useQuery override * Test prefetch warnings * Remove inadvertent/unnecessary diff * Remove comments * Prefetch homepage. Invalidate learning resource cache items * Remove comment * Update comment * Temp remove featured resource list shuffle * Remove unused * Prefetch calls * Prefetch topics page * Rename key factory re-exports * Units page prefetch * Single request for all unit channel details * Update unit listing page tests * Page arg types * Optional route params * Remove comment * Remove unused * Remove comment * Reinstate featured list shuffle and remove cache invalidation to refetch resources for user * Add news to server render
What are the relevant tickets?
Closes:
Next.js: Homepage: Prefetch API calls #5920
Next.js: Topics, Units and Channels pages: Prefetch API calls #6036
Description (What does it do?)
This PR reinstates #1822, which was approved/merged but reverted as it included cache invalidation for learning resources to refetched them in the client to get the list memberships that did not work for all cases. This PR removes the need for it: #1846 as it fetches memberships independently from the learning resources.
Homepage
Makes API calls needed to render homepage learning resources on the server so that these prerender:
Unit Listing page /units
Updates to make a single call
/api/v0/channels/?channel_type=unit
, replacing calls to each channel detail page in the unit cards. Prefetches channels list and count by unit.Topics Listing page /topics
Prefetches topics list and counts by topic.
How can this be tested?
These routes should server render all public content without any prefetch mismatch warnings in the browser console:
Pages should render on first load with content with JavaScript disabled in the dev tools debugger settings.
Additional Context
Also adds reusable server PageParams type and cleans up the api key factory imports.