Description
Currently, the serveHtml function reads HTML files from the disk on every incoming request using fs.readFile. While fs.readFile is asynchronous, reading from the disk repeatedly for static templates introduces unnecessary I/O overhead under heavy traffic. Since our frontend pages only change during a new deployment, we can optimize server efficiency by caching the file contents in memory after the first read.
Why this is Safe and Efficient
- Efficient RAM Utilization: The template is stored exactly once in the central server's RAM. Whether 1 user or 1,000 users connect, memory usage does not multiply because they all read from the same cached reference.
- Preserved Security: The security nonces (
__NONCE__) will remain completely dynamic and unique per user request because the string replacement operation will still occur on the cached template in real-time on every request.
Expected Behavior
- Drastic Reduction in Disk I/O: Bypasses filesystem operations completely for subsequent route requests (
/', /leaderboard`, etc.).
- Improved TTFB (Time to First Byte): Faster server response times under concurrent user loads.
Please assign this issue to me!
Description
Currently, the
serveHtmlfunction reads HTML files from the disk on every incoming request usingfs.readFile. Whilefs.readFileis asynchronous, reading from the disk repeatedly for static templates introduces unnecessary I/O overhead under heavy traffic. Since our frontend pages only change during a new deployment, we can optimize server efficiency by caching the file contents in memory after the first read.Why this is Safe and Efficient
__NONCE__) will remain completely dynamic and unique per user request because the string replacement operation will still occur on the cached template in real-time on every request.Expected Behavior
/',/leaderboard`, etc.).Please assign this issue to me!