title: Nginx php files loading slow
body: <p>EDIT: I have noticed the first time you visit it to goes fast, and it also goes fast if you close the browser tab and re-visit it, but if you simply reload or visit it when you have a tab of it open it goes slow, it is really confusing.</p>
  
  <p>today I come with a problem about PHP CGI, I am brand new to nginx and have just installed it, when I noticed I need to start PHP cgi also with it because with IIS it started it for me. so I start php with batch file below but the problem is... slow php files, they load really slowly even if its just html in them.</p>
  
  <pre><code>@ECHO off
  echo Starting PHP, please wait!
  C:\nginx\php7\php-cgi.exe -b 127.0.0.1:9054 -c C:\nginx\php7\php.ini
  ping 127.0.0.1 -n 1&gt;NUL
  ping 127.0.0.1 &gt;NUL
  EXIT
  </code></pre>
  
  <p>Am I doing anything wrong with my batch file or nginx config below? (I have 2 configs) the example.com one is the website with a .php file and the nginx (localhost) just has index.html</p>
  
  <p>localhost loads super fast but example.com one loads really slow because of php.</p>
  
  <p>nginx.conf
      worker_processes  1;</p>
  
  <pre><code>#error_log  logs/error.log;
  #error_log  logs/error.log  notice;
  #error_log  logs/error.log  info;
  
  #pid        logs/nginx.pid;
  
  
  events {
      worker_connections  1024;
  }
  
  
  http {
      include       mime.types;
      default_type  application/octet-stream;
  
      #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
      #                  '$status $body_bytes_sent "$http_referer" '
      #                  '"$http_user_agent" "$http_x_forwarded_for"';
  
      #access_log  logs/access.log  main;
  
      sendfile        on;
      #tcp_nopush     on;
  
      #keepalive_timeout  0;
      keepalive_timeout  65;
  
      #gzip  on;
  
      server {
          listen       80;
          server_name  localhost;
  
          #charset koi8-r;
  
          #access_log  logs/host.access.log  main;
  
          location / {
              root   C:\Users\Administrator\Dropbox\websites\local_website;
              index  index.html index.htm;
          }
          error_page   500 502 503 504  /50x.html;
          location = /50x.html {
              root   html;
          }
  
          location ~ \.php$ {
              if (!-e $document_root$document_uri){return 404;}
              fastcgi_pass localhost:9054;
              fastcgi_index index.php;
              fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
              include fastcgi_params;
          }
      }
  
      include vhosts/*.conf;
  }
  </code></pre>
  
  <p>example.com.conf</p>
  
  <pre><code>server {
      listen   ***.***.**.***:80;
      server_name  example.com www.example.com;
  
      root C:\Users\Administrator\Dropbox\websites\php_website;
      index index.php index.html;
  
      log_not_found off;
      charset utf-8;
  
      #access_log  logs/example.com-access.log  main;
  
      location ~ /\. {allow all;}
  
      location / {
          rewrite ^/(|/)$ /index.php?url=$1;
          rewrite ^/([a-zA-Z0-9_-]+)(|/)$ /index.php?url=$1;
          rewrite ^/(.*)\.htm$ /$1.php;
      }
  
      location = /favicon.ico {
      }
  
      location = /robots.txt {
      }
  
      location ~ \.php$ {
          if (!-e $document_root$document_uri){return 404;}
          fastcgi_pass localhost:9054;
          fastcgi_index index.php;
          fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
          include fastcgi_params;
      }
  }
  </code></pre>