Pre-rendered content is stored and treated differently than normal Netlify website cache. For example, the primary difference is that, the pre-rendered data is stored for 48 hours unlike the normal cache that’s invalidated as soon as you publish a new build - so sometimes bots continue to see outdated content.
I’m not saying it would solve the problem, it’s just that it might. I think it might because the 504 is only received by the user agents used by bots - no real user traffic for your site got 504 error code. Also, Netlify is a static file CDN + you’re not using Server Side Rendering - in this scenario, there’s no reason for a website to get
5xx errors as those are ‘server-side’ errors, but Netlify is merely sending the file requested by the browser back to it without any kind of processing.