Skip to content

perf(dev-cache): improve localhost markdown page navigation performance (when having 2,000+ pages)#2675

Merged
farnabaz merged 3 commits intonuxt:mainfrom
coffeephile:fix/localhost-perf-cache-contents
Jun 25, 2024
Merged

perf(dev-cache): improve localhost markdown page navigation performance (when having 2,000+ pages)#2675
farnabaz merged 3 commits intonuxt:mainfrom
coffeephile:fix/localhost-perf-cache-contents

Conversation

@coffeephile
Copy link
Copy Markdown
Contributor

🔗 Linked issue

#2674

❓ Type of change

  • 📖 Documentation (updates to the documentation or readme)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • 👌 Enhancement (improving an existing functionality like performance)
  • ✨ New feature (a non-breaking change that adds functionality)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

📚 Description

Resolves #2674

Navigating between markdown pages on localhost (dev server) is very slow when dealing with 2,000+ markdown pages.
(Please refer to linked issue for demo and reproduction)

By using cachedContents on localhost as well (not only during build time) this issue can be resolved.
In order to keep hot reload working, the cache gets flushed when a file change is detected.

I confirmed my fix to be working for my use case, however I'm not sure if I am breaking anything else in the process, so any advice or help is welcome.
This PR should be considered a first draft, rather than a perfect solution. 🙇‍♂️

📝 Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

Copy link
Copy Markdown
Member

@farnabaz farnabaz left a comment

Choose a reason for hiding this comment

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

By removing the prerendering check, we are changing the behavior of the production environment too.
We should add back prerendering check and add logic to handle dev mode

@coffeephile
Copy link
Copy Markdown
Contributor Author

@farnabaz Many thanks for your swift review, much appreciated! 🙏

I've implemented the changes you suggested, please check again 🙇‍♂️

@coffeephile coffeephile requested a review from farnabaz June 24, 2024 00:31
Copy link
Copy Markdown
Member

@farnabaz farnabaz left a comment

Choose a reason for hiding this comment

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

LGTM 👍
Thanks

@farnabaz farnabaz merged commit 5672457 into nuxt:main Jun 25, 2024
@coffeephile
Copy link
Copy Markdown
Contributor Author

Thank you! 🙏😊

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.

Markdown page navigation slow on dev server when having multiple thousand md pages

2 participants