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

bugfix(website): caching of transparency page #495

Merged
merged 4 commits into from
Aug 8, 2023
Merged

bugfix(website): caching of transparency page #495

merged 4 commits into from
Aug 8, 2023

Conversation

andrashee
Copy link
Contributor

@mkue Like this, it works for me. It seems to me, that providing the TransparencyPageProps to the TransparencyCharts is causing the reevaluation of getStats in each request. Something in there makes the caching obsolete. Providing the parameters explicitly, the caching and reevaluation seems to work fine.

@vercel
Copy link

vercel bot commented Aug 8, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Ignored Deployment
Name Status Preview Comments Updated (UTC)
public ⬜️ Ignored (Inspect) Visit Preview Aug 8, 2023 8:46pm

@andrashee andrashee changed the title [bugfix] Caching of Transparency Page [bugfix(website)] Caching of Transparency Page Aug 8, 2023
@andrashee andrashee changed the title [bugfix(website)] Caching of Transparency Page bugfix(website): caching of Transparency Page Aug 8, 2023
@andrashee andrashee changed the title bugfix(website): caching of Transparency Page bugfix(website): caching of transparency page Aug 8, 2023
@@ -26,7 +39,12 @@ export default async function Page(props: TransparencyPageProps) {
<Stats.Stat.Item variant="value">{contributionStats.totalContributions}</Stats.Stat.Item>
</Stats.Stat>
</Stats>
<TransparencyCharts contributionStats={contributionStats} paymentStats={paymentStats} {...props} />
<TransparencyCharts
Copy link
Contributor

@mkue mkue Aug 8, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you realize that this is the absolute crucial change?

Without this change, the caching doesn't work. But with this change, it doesn't matter if you leave the getStats() function in a separate file, wrap it inside a cache() call, or specify export const revalidate = 3600;. All these things don't matter in this case. All that matters for the caching to work is to not use the spread (...) operator on the page props. I'm so confused 🤯. I guess it's never a good idea to use ...props with page components.

Obviously, specifying export const revalidate = 3600; makes sense; otherwise the stats are never updated.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops, I only now saw your comment from above🙈😅 I'll merge the changes.

Copy link
Contributor

@mkue mkue left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very cool! Thanks a lot for looking into this. I don't really understand what the issue was before with using the spread operator (see my comment), but at least it works now :)

@mkue mkue merged commit cb6334f into main Aug 8, 2023
17 checks passed
@mkue mkue deleted the ahee/revalidate branch August 8, 2023 20:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants