Getting 503 error and need to refresh 3-4 times before everything loads when behind proxy

I have no issue accessing the webpage, however I need to reload it 3-4 before every item loads and is cached.

I do have other services behind my proxy that works fine.

I am using nginx proxy manager with the following settings

scheme: http
cache assets: true
block common epxloits: true
websockets support: false

SSL:
force SSL: true
http/2 support: true
hsts enabled: true
hsts subdomains: true

in advanced I have

proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Connection "";
proxy_connect_timeout 300s;
proxy_send_timeout 300s;
proxy_read_timeout 300s;
send_timeout 300s;

My docker compose file is below

version: '3.8'
services:
  wordpress:
    image: wordpress:latest
    container_name: wordpress
    restart: always
    ports:
      - "8082:80"
    environment:
      WORDPRESS_DB_HOST: db:3306
      WORDPRESS_DB_USER: wordpress_user
      WORDPRESS_DB_PASSWORD: wordpress_password
      WORDPRESS_DB_NAME: wordpress_db
      PHP_UPLOAD_MAX_FILESIZE: 64M
      PHP_POST_MAX_SIZE: 64M
      PHP_MAX_EXECUTION_TIME: 600
      PHP_MEMORY_LIMIT: 1024M
      PHP_MAX_INPUT_TIME: 600
      PHP_MAX_INPUT_VARS: 3000
    volumes:
      - wordpress_data:/var/www/html
      - ./custom-php.ini:/usr/local/etc/php/conf.d/custom-php.ini:ro
      - ./wp-config.php:/var/www/html/wp-config.php:ro
      - ./debug.log:/var/www/html/wp-content/debug.log
      - ./info.php:/var/www/html/info.php:ro 
    deploy:
      resources:
        limits:
          cpus: '3.5'
          memory: 2G
        reservations:
          cpus: '1.5'
          memory: 512M
    depends_on:
      - db

  db:
    image: mysql:8
    container_name: wordpress_db
    restart: always
    environment:
      MYSQL_DATABASE: wordpress_db
      MYSQL_USER: wordpress_user
      MYSQL_PASSWORD: wordpress_password
      MYSQL_ROOT_PASSWORD: root_password
    volumes:
      - wordpress_db_data:/var/lib/mysql

  phpmyadmin:
    image: phpmyadmin/phpmyadmin
    container_name: phpmyadmin
    restart: always
    ports:
      - "8083:80"
    environment:
      PMA_HOST: db
      MYSQL_ROOT_PASSWORD: root_password
    depends_on:
      - db


volumes:
  wordpress_data:
  wordpress_db_data:

The custom-php.ini

; File upload settings
upload_max_filesize = 64M
post_max_size = 64M

; Execution time and memory
max_execution_time = 300
memory_limit = 256M
max_input_time = 300
max_input_vars = 3000

; Error reporting (for production)
error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT
display_errors = Off
display_startup_errors = Off
log_errors = On
error_log = /var/log/php/error.log

; OPcache settings
opcache.enable = 1
opcache.memory_consumption = 128
opcache.interned_strings_buffer = 8
opcache.max_accelerated_files = 4000
opcache.revalidate_freq = 60
opcache.fast_shutdown = 1

; Performance settings
realpath_cache_size = 4096k
realpath_cache_ttl = 600

; Security settings
expose_php = Off
session.cookie_httponly = 1
session.use_only_cookies = 1
session.cookie_secure = 1

; MySQL settings
mysql.allow_persistent = On
mysqli.allow_persistent = On

The Issue:

After I install a theme I have to reload the webpage 3-4 times before I have all elements loaded. For some reason I get a 503 error (net::ERR_ABORTED 503 (Service Unavailable)), but after 3-4 refreshes with either ctrl+R or F5 it works. But when I do a ctrl+shift+R refresh then I have to refresh it all again 3-4 times for properly working

When I open the developer tab and look at the network tab it seems that the calls are simply stopping and no more calls are made. Then when I refresh the pictures/files are cached and it can make more calls to the server

The docker stats. On a reload I hit 30-40% on the wordpress container

CONTAINER ID   NAME           CPU %     MEM USAGE / LIMIT     MEM %     NET I/O          BLOCK I/O     PIDS
3bea8e5a1c28   phpmyadmin     0.01%     12.01MiB / 62.35GiB   0.02%     1.53kB / 0B      0B / 16.4kB   6
bb164fad39ef   wordpress      0.01%     166.4MiB / 3GiB       5.42%     18.9MB / 366kB   0B / 172kB    9
eef2153ef316   wordpress_db   0.17%     205.1MiB / 62.35GiB   0.32%     237kB / 18.8MB   0B / 26.5MB   29

files not loaded from a fresh reload

face4-circle.jpg503text/html(index):1786596 B33 ms
face1-circle.jpg503text/html(index):1354596 B5 ms
face2-circle.jpg503text/html(index):1434596 B5 ms
face3-circle.jpg503text/html(index):1866596 B46 ms

after two another refresh:

Sounds more like an application issue than a Docker issue.