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

perf: Optimize i18n instance caching in App Router #18309

Merged
merged 2 commits into from
Dec 23, 2024

Conversation

hbjORbj
Copy link
Contributor

@hbjORbj hbjORbj commented Dec 20, 2024

What does this PR do?

  1. Added module-level caching for i18n instances to prevent unnecessary recreation
  2. Confirmed that there's no instance of getFixedT util
  • This change improves translation loading performance by reusing i18n instances across requests while maintaining the same functionality.

  • Before: Each translation request would create a new i18n instance

  • After: i18n instances are cached and reused based on locale-namespace combinations

Mandatory Tasks (DO NOT REMOVE)

  • I have self-reviewed the code (A decent size PR without self-review might be rejected).
  • N/A - I have updated the developer docs in /docs if this PR makes changes that would require a documentation change. If N/A, write N/A here and check the checkbox.
  • I confirm automated tests are in place that prove my fix is effective or that my feature works.

How should this be tested?

  • Please use the latest Vercel preview and test please 🙏.

Copy link

vercel bot commented Dec 20, 2024

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

2 Skipped Deployments
Name Status Preview Comments Updated (UTC)
cal ⬜️ Ignored (Inspect) Visit Preview Dec 23, 2024 4:55pm
calcom-web-canary ⬜️ Ignored (Inspect) Visit Preview Dec 23, 2024 4:55pm

@graphite-app graphite-app bot requested a review from a team December 20, 2024 20:54
@dosubot dosubot bot added the i18n area: i18n, translations label Dec 20, 2024
@keithwillcode keithwillcode added consumer core area: core, team members only labels Dec 20, 2024
@hbjORbj hbjORbj changed the title chore: cache i18n instance chore: Optimize i18n instance caching in App Router Dec 20, 2024
Copy link

graphite-app bot commented Dec 20, 2024

Graphite Automations

"Add consumer team as reviewer" took an action on this PR • (12/20/24)

1 reviewer was added to this PR based on Keith Williams's automation.

@hbjORbj hbjORbj changed the title chore: Optimize i18n instance caching in App Router perf: Optimize i18n instance caching in App Router Dec 20, 2024
@hbjORbj hbjORbj enabled auto-merge (squash) December 20, 2024 20:58
@hbjORbj hbjORbj added ready-for-e2e performance area: performance, page load, slow, slow endpoints, loading screen, unresponsive labels Dec 20, 2024
Copy link
Contributor

github-actions bot commented Dec 20, 2024

E2E results are ready!

@@ -44,31 +55,21 @@ export const _generateMetadata = async (
const h = headers();
const canonical = h.get("x-pathname") ?? "";
const locale = h.get("x-locale") ?? "en";

const t = await getFixedT(locale, "common");
const t = await getTranslationWithCache(locale);
Copy link
Contributor

Choose a reason for hiding this comment

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

NIT: we could even replace this with getTranslate()

@eunjae-lee
Copy link
Contributor

eunjae-lee commented Dec 23, 2024

@hbjORbj no preview available 🤔

Screenshot 2024-12-23 at 10 47 51

(the code change looks good, but i haven't tested it yet)

@hbjORbj hbjORbj merged commit 5fe4e09 into main Dec 23, 2024
38 checks passed
@hbjORbj hbjORbj deleted the chore/cache-i18n-instance branch December 23, 2024 17:14
nizzyabi pushed a commit that referenced this pull request Dec 26, 2024
emrysal added a commit that referenced this pull request Dec 26, 2024
* plain custom desin

* No display on card

* dynamic plain chat component and hmac hash

* re-route users to plain.com chat instead of intercom chat when going to /support

* provider errors

* yarn lock fix

* plain chat removed unneeded hmac

* fix ts error

* error handling improved

* remove intercome provider from app-dir

* Create getting-started.mdx (#18342)

* Delete help directory (#18343)

* chore: moved docs/help to /help (#18345)

* chore: Delete unused guides directory (#18346)

* feat: booking filters (#18303)

Co-authored-by: Syed Ali Shahbaz <[email protected]>

* chore: Remove `HeadSeo` components where no longer needed + improve app router metadata logic (#18348)

* remove HeadSeo for already migrated pages and refactor prepareMetadata

* create _generateMetadataWithoutImage and refactor _generateMetadata

* chore: app router - /bookings status page (#18183)

* chore: app router - /bookings page

* remove env vars

* fix

* Update middleware.ts

* revert unneeded change

* refactor for the better

* fix

* cache i18n instances (#18309)

* feat: virtual queues tab in insights (#18260)

Co-authored-by: CarinaWolli <[email protected]>
Co-authored-by: sean-brydon <[email protected]>
Co-authored-by: sean-brydon <[email protected]>
Co-authored-by: Peer Richelsen <[email protected]>
Co-authored-by: Omar López <[email protected]>

* feat: update translations via @replexica (#18361)

Co-authored-by: Replexica <[email protected]>

* update OOO e2e tests to remove flakiness (#18367)

* fix: metadata is overwritten for child managed eventType when updating parent (#18059)

* fix: metadata is overwirten

* Update

* type error

* Update

* fix test

* fix type error

* chore: added routing support link (#18369)

* Added routing form support link

* small change

* Type fix

---------

Co-authored-by: Joe Au-Yeung <[email protected]>

* chore: refactor handling logic for embeds in app router (#18362)

* refactor handling logic for embeds in app router

* fix type checks

* add test for withEmbedSsrAppDir

* fix

* review changes

* yarn lock

---------

Co-authored-by: Peer Richelsen <[email protected]>
Co-authored-by: Calcom Bot <[email protected]>
Co-authored-by: Udit Takkar <[email protected]>
Co-authored-by: Syed Ali Shahbaz <[email protected]>
Co-authored-by: Benny Joo <[email protected]>
Co-authored-by: Carina Wollendorfer <[email protected]>
Co-authored-by: CarinaWolli <[email protected]>
Co-authored-by: sean-brydon <[email protected]>
Co-authored-by: sean-brydon <[email protected]>
Co-authored-by: Omar López <[email protected]>
Co-authored-by: Replexica <[email protected]>
Co-authored-by: Vijay <[email protected]>
Co-authored-by: Anik Dhabal Babu <[email protected]>
Co-authored-by: Joe Au-Yeung <[email protected]>
Co-authored-by: Alex van Andel <[email protected]>
joeauyeung added a commit that referenced this pull request Jan 5, 2025
* plain custom desin

* No display on card

* dynamic plain chat component and hmac hash

* re-route users to plain.com chat instead of intercom chat when going to /support

* provider errors

* yarn lock fix

* plain chat removed unneeded hmac

* fix ts error

* error handling improved

* remove intercome provider from app-dir

* Create getting-started.mdx (#18342)

* Delete help directory (#18343)

* chore: moved docs/help to /help (#18345)

* chore: Delete unused guides directory (#18346)

* feat: booking filters (#18303)

Co-authored-by: Syed Ali Shahbaz <[email protected]>

* chore: Remove `HeadSeo` components where no longer needed + improve app router metadata logic (#18348)

* remove HeadSeo for already migrated pages and refactor prepareMetadata

* create _generateMetadataWithoutImage and refactor _generateMetadata

* chore: app router - /bookings status page (#18183)

* chore: app router - /bookings page

* remove env vars

* fix

* Update middleware.ts

* revert unneeded change

* refactor for the better

* fix

* cache i18n instances (#18309)

* feat: virtual queues tab in insights (#18260)

Co-authored-by: CarinaWolli <[email protected]>
Co-authored-by: sean-brydon <[email protected]>
Co-authored-by: sean-brydon <[email protected]>
Co-authored-by: Peer Richelsen <[email protected]>
Co-authored-by: Omar López <[email protected]>

* feat: update translations via @replexica (#18361)

Co-authored-by: Replexica <[email protected]>

* update OOO e2e tests to remove flakiness (#18367)

* fix: metadata is overwritten for child managed eventType when updating parent (#18059)

* fix: metadata is overwirten

* Update

* type error

* Update

* fix test

* fix type error

* chore: added routing support link (#18369)

* Added routing form support link

* small change

* Type fix

---------

Co-authored-by: Joe Au-Yeung <[email protected]>

* chore: refactor handling logic for embeds in app router (#18362)

* refactor handling logic for embeds in app router

* fix type checks

* add test for withEmbedSsrAppDir

* fix

* review changes

* yarn lock

---------

Co-authored-by: Peer Richelsen <[email protected]>
Co-authored-by: Calcom Bot <[email protected]>
Co-authored-by: Udit Takkar <[email protected]>
Co-authored-by: Syed Ali Shahbaz <[email protected]>
Co-authored-by: Benny Joo <[email protected]>
Co-authored-by: Carina Wollendorfer <[email protected]>
Co-authored-by: CarinaWolli <[email protected]>
Co-authored-by: sean-brydon <[email protected]>
Co-authored-by: sean-brydon <[email protected]>
Co-authored-by: Omar López <[email protected]>
Co-authored-by: Replexica <[email protected]>
Co-authored-by: Vijay <[email protected]>
Co-authored-by: Anik Dhabal Babu <[email protected]>
Co-authored-by: Joe Au-Yeung <[email protected]>
Co-authored-by: Alex van Andel <[email protected]>
MuhammadAimanSulaiman pushed a commit to hit-pay/cal.com that referenced this pull request Jan 10, 2025
MuhammadAimanSulaiman pushed a commit to hit-pay/cal.com that referenced this pull request Jan 10, 2025
* plain custom desin

* No display on card

* dynamic plain chat component and hmac hash

* re-route users to plain.com chat instead of intercom chat when going to /support

* provider errors

* yarn lock fix

* plain chat removed unneeded hmac

* fix ts error

* error handling improved

* remove intercome provider from app-dir

* Create getting-started.mdx (calcom#18342)

* Delete help directory (calcom#18343)

* chore: moved docs/help to /help (calcom#18345)

* chore: Delete unused guides directory (calcom#18346)

* feat: booking filters (calcom#18303)

Co-authored-by: Syed Ali Shahbaz <[email protected]>

* chore: Remove `HeadSeo` components where no longer needed + improve app router metadata logic (calcom#18348)

* remove HeadSeo for already migrated pages and refactor prepareMetadata

* create _generateMetadataWithoutImage and refactor _generateMetadata

* chore: app router - /bookings status page (calcom#18183)

* chore: app router - /bookings page

* remove env vars

* fix

* Update middleware.ts

* revert unneeded change

* refactor for the better

* fix

* cache i18n instances (calcom#18309)

* feat: virtual queues tab in insights (calcom#18260)

Co-authored-by: CarinaWolli <[email protected]>
Co-authored-by: sean-brydon <[email protected]>
Co-authored-by: sean-brydon <[email protected]>
Co-authored-by: Peer Richelsen <[email protected]>
Co-authored-by: Omar López <[email protected]>

* feat: update translations via @replexica (calcom#18361)

Co-authored-by: Replexica <[email protected]>

* update OOO e2e tests to remove flakiness (calcom#18367)

* fix: metadata is overwritten for child managed eventType when updating parent (calcom#18059)

* fix: metadata is overwirten

* Update

* type error

* Update

* fix test

* fix type error

* chore: added routing support link (calcom#18369)

* Added routing form support link

* small change

* Type fix

---------

Co-authored-by: Joe Au-Yeung <[email protected]>

* chore: refactor handling logic for embeds in app router (calcom#18362)

* refactor handling logic for embeds in app router

* fix type checks

* add test for withEmbedSsrAppDir

* fix

* review changes

* yarn lock

---------

Co-authored-by: Peer Richelsen <[email protected]>
Co-authored-by: Calcom Bot <[email protected]>
Co-authored-by: Udit Takkar <[email protected]>
Co-authored-by: Syed Ali Shahbaz <[email protected]>
Co-authored-by: Benny Joo <[email protected]>
Co-authored-by: Carina Wollendorfer <[email protected]>
Co-authored-by: CarinaWolli <[email protected]>
Co-authored-by: sean-brydon <[email protected]>
Co-authored-by: sean-brydon <[email protected]>
Co-authored-by: Omar López <[email protected]>
Co-authored-by: Replexica <[email protected]>
Co-authored-by: Vijay <[email protected]>
Co-authored-by: Anik Dhabal Babu <[email protected]>
Co-authored-by: Joe Au-Yeung <[email protected]>
Co-authored-by: Alex van Andel <[email protected]>
MuhammadAimanSulaiman pushed a commit to hit-pay/cal.com that referenced this pull request Feb 20, 2025
MuhammadAimanSulaiman pushed a commit to hit-pay/cal.com that referenced this pull request Feb 20, 2025
* plain custom desin

* No display on card

* dynamic plain chat component and hmac hash

* re-route users to plain.com chat instead of intercom chat when going to /support

* provider errors

* yarn lock fix

* plain chat removed unneeded hmac

* fix ts error

* error handling improved

* remove intercome provider from app-dir

* Create getting-started.mdx (calcom#18342)

* Delete help directory (calcom#18343)

* chore: moved docs/help to /help (calcom#18345)

* chore: Delete unused guides directory (calcom#18346)

* feat: booking filters (calcom#18303)

Co-authored-by: Syed Ali Shahbaz <[email protected]>

* chore: Remove `HeadSeo` components where no longer needed + improve app router metadata logic (calcom#18348)

* remove HeadSeo for already migrated pages and refactor prepareMetadata

* create _generateMetadataWithoutImage and refactor _generateMetadata

* chore: app router - /bookings status page (calcom#18183)

* chore: app router - /bookings page

* remove env vars

* fix

* Update middleware.ts

* revert unneeded change

* refactor for the better

* fix

* cache i18n instances (calcom#18309)

* feat: virtual queues tab in insights (calcom#18260)

Co-authored-by: CarinaWolli <[email protected]>
Co-authored-by: sean-brydon <[email protected]>
Co-authored-by: sean-brydon <[email protected]>
Co-authored-by: Peer Richelsen <[email protected]>
Co-authored-by: Omar López <[email protected]>

* feat: update translations via @replexica (calcom#18361)

Co-authored-by: Replexica <[email protected]>

* update OOO e2e tests to remove flakiness (calcom#18367)

* fix: metadata is overwritten for child managed eventType when updating parent (calcom#18059)

* fix: metadata is overwirten

* Update

* type error

* Update

* fix test

* fix type error

* chore: added routing support link (calcom#18369)

* Added routing form support link

* small change

* Type fix

---------

Co-authored-by: Joe Au-Yeung <[email protected]>

* chore: refactor handling logic for embeds in app router (calcom#18362)

* refactor handling logic for embeds in app router

* fix type checks

* add test for withEmbedSsrAppDir

* fix

* review changes

* yarn lock

---------

Co-authored-by: Peer Richelsen <[email protected]>
Co-authored-by: Calcom Bot <[email protected]>
Co-authored-by: Udit Takkar <[email protected]>
Co-authored-by: Syed Ali Shahbaz <[email protected]>
Co-authored-by: Benny Joo <[email protected]>
Co-authored-by: Carina Wollendorfer <[email protected]>
Co-authored-by: CarinaWolli <[email protected]>
Co-authored-by: sean-brydon <[email protected]>
Co-authored-by: sean-brydon <[email protected]>
Co-authored-by: Omar López <[email protected]>
Co-authored-by: Replexica <[email protected]>
Co-authored-by: Vijay <[email protected]>
Co-authored-by: Anik Dhabal Babu <[email protected]>
Co-authored-by: Joe Au-Yeung <[email protected]>
Co-authored-by: Alex van Andel <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
consumer core area: core, team members only i18n area: i18n, translations performance area: performance, page load, slow, slow endpoints, loading screen, unresponsive ready-for-e2e
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants