ImmichI
Immich8mo ago
veil

(Solved) Immich behind reverse proxy very slow initial load in browser or app

Hi all. I’ve been using Immich for a long time, actually using it via Portainer. It works fine, but every day when I open Immich in a browser, the first 1–2 attempts just “loadaing” and then throw a 500 Internal Error. But for the ~ 3-4. attempt it loads fine and works smoothly… until the next day, when slowness starts again. Tested with multiple devices and with different ISPs in different cities. I’ve tried using Immich with Nginx, NPM, NPM Plus and now Caddy, but all of them had some speed issues. Other containers running through Caddy work fast. I assume the problem is something like Immich frontend is loading slowly, or some caching problems, IDK. I checked all 4 container logs (debug mode), but no errors.
So my question is: What could cause Immich to be so slow when accessed via internet (reverse proxy) for the first time on a day? Now it works fine and flawlessly for me, but if I open it from another device or in incognito/private mode, the loading speed is slow again. Once it is loaded, then it's fast, thumnails are there, etc. I use it behind Cloudflare, but even with Proxied or DNS Only mode, the issue remains. I have no idea.
Solution
Ok, problem solved. Below you can see my summary:

Immich was extremely slow or failed to load initially in any web browsers, both in normal and in incognito mode. Many static asset requests (/_app/immutable/...) failed with 522 errors or returned the wrong Content-Type (text/html instead of text/javascript), breaking the frontend.

Root Causes Identified & Fixed:
  • Cloudflare proxy (orange cloud) was enabled, which interfered with streaming JS modules and chunked asset delivery. This caused intermittent 522 and CORS-related failures.
  • Stale in-memory browser cache in private sessions preserved bad HTML responses as JS, compounding errors.
Solutions Applied:
  • Switched Cloudflare DNS to DNS-only (grey cloud) — resolved all CDN-induced issues.
  • Increased Caddy proxy timeouts to ensure larger responses weren't prematurely cut off (maybe it is not necessary at all)
Was this page helpful?