I haven't seen your code but looking at your code snippet I can suggest some solutions to optimize your metadata. You don't need to create a separate Custom Type for metadata. Add metadata field in the about Custom Type in a different tab. For example:
Go to your Custom Type where you want to add the metadata.
Click on the "+" sign next to the main tab and name it "SEO."
Add the metadata fields to that tab.
A Key Text field for the meta title( API ID: meta_title).
A Key Text field for the meta description( API ID: meta_desc).
In that way, you don't need 2 calls in one route to get content. Only query the about page and template SEO/Meta fields in the head section of the about templating section.
Thanks @Priyanka ! I feel it made no difference in the wait time, but it looks and feels way cleaner this way.
But the TTFB is still a bit slow, having wait times between 200ms and 600ms. It's way better when I switched to CDN, but it's still very slow for what it should be. I've seen prismic websites with much much lower TTFB values and I'm wondering how they do it?
And since this is basically raw Javascript with Express shouldn't it be faster?
Hi @amarinofr
I will check with my team to see other optimizations can be done; I don't have more stuff to optimize other than what @Priyanka has proposed, but converting to one API call should have made a difference.
I am facing the same issue from the same course on awwards
I have changed my approach based on the discussion above, making only one specific fetch call based on the current page, but there's still an unusual delay
Welcome to the Prismic community, and thanks for reaching out to us.
You should use the latest prismic packages versions like @prismicio/client, @prismicio/helpers and where you don't need prismic-dom. Also, create a client function where you don't need req params.
I will suggest you change the setup and follow the article: Set up Prismic with Express - Documentation - Prismic
Give this a try and let me know if you need anything else.
Evreything looks good to me. One thing I would change is to use import method instead require method. Loading is synchronous(step by step) for require on the other hand import can be asynchronous(without waiting for previous import) so it can perform a little better than require
Hello @neelansh448, I am not sure about the root cause of the slow time. I can try to run your project on my locale if you share the github repo or project source code with me. You can send me via private message.