I have a PHP web page which load a lot of files (1412 request are to be processed)
If I load the page for the first time there are no problems. Reloading the page cause the error 502 for the last 182 requests.
I had some version of the Caddyfile wich all worked well.
The problem is within php-cgi. I fixed this with setting and exporting PHP_FCGI_MAX_REQUESTS=0 before of lauching php-cgi.
I Work under Linux and use at this time caddy 1.0.3