events have two primary issues, one is that the load from firebase is relatively slow causing problems with page hydration, and another is that vercel has no way to cache requests on on the filesystem.
To some extent this is mitigated by using an in-memory cache for the serverless script to reduce round trip times between cache calls, however that is only maintained during the lifetime of the lambda. From cold, the script is noticeably slow. The cache could be prewarmed by having a static cache set as an envvar on vercel and doing a differential update.
This would best be handled by using a custom store instead of a fetch event, which would allow the event data itself to be properly managed by combining the fast load of a static asset that is pregenerated at build time along with a real-time update on page load, continuing to take advantage of the serverless functions.
events have two primary issues, one is that the load from firebase is relatively slow causing problems with page hydration, and another is that vercel has no way to cache requests on on the filesystem.
To some extent this is mitigated by using an in-memory cache for the serverless script to reduce round trip times between cache calls, however that is only maintained during the lifetime of the lambda. From cold, the script is noticeably slow. The cache could be prewarmed by having a static cache set as an envvar on vercel and doing a differential update.
This would best be handled by using a custom store instead of a fetch event, which would allow the event data itself to be properly managed by combining the fast load of a static asset that is pregenerated at build time along with a real-time update on page load, continuing to take advantage of the serverless functions.