title: How can I disable caching in nginx?
body: <p>I'm not familiar with nginx and have trouble editing/fixing a php script served through nginx. My fixes are not visible- it seems the script file (or its output) are cached, probably by nginx. The config files do NOT contain any <code>fastcgi_cache</code> directives though.</p>
  
  <p>What do I need to change to be able to edit the php script and see its updated output?</p>
  
  <p>php version is 5.4, so it's not opcache-related. It's also not browser-related as the same happens with different browsers, wget etc.</p>
  
  <p><em>nginx config:</em></p>
  
  <pre><code>user root users;
  worker_processes  1;
  
  #error_log  logs/error.log;
  error_log  /var/log/nginx/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;
  
      #access_log  logs/access.log  main;
  
      sendfile        on;
      #keepalive_timeout  0;
      keepalive_timeout  65;
  
      gzip  off;
      proxy_buffering off;
      fastcgi_keep_conn on;
  
      #start server1 section
      server {
      listen       80;
      access_log  /var/log/nginx/access.log;
      location / {
          root   /var/www;
          index  index.php index.html index.htm;
      }
  
      location /db {
      proxy_pass        http://localhost:81/;
      }
  
      location /command {
      proxy_pass        http://localhost:82/;
      }
  
      # redirect server error pages to the static page /50x.html
      #
      error_page   500 502 503 504  /50x.html;
      location = /50x.html {
          root   html;
      }
      # php5-fpm
      location ~ \.php$ {
          root           /var/www;
          fastcgi_pass   127.0.0.1:9000;
          fastcgi_index  index.php;
          #fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
          include        fastcgi_params;
          fastcgi_param SCRIPT_FILENAME $request_filename;
          fastcgi_read_timeout 3600;
      }
      } #end server1 section
  
      #start server2 section [/db]
      server {
      listen       81;
      access_log  /var/log/nginx/db.log;
      location / {
          root   /var/www/db;
          index  index.php;
      }
      # php5-fpm
      location ~ \.php$ {
          root           /var/www/db;
          fastcgi_pass   127.0.0.1:9001;
          fastcgi_index  index.php;
          #fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
          include        fastcgi_params;
          fastcgi_param SCRIPT_FILENAME $request_filename;
          fastcgi_read_timeout 3600;
      }
      } #end server2 section
  
      #start server3 section [/command]
      server {
      listen       82;
      access_log  /var/log/nginx/command.log;
      location / {
          root   /var/www/command;
          index  index.php;
      }
      # php5-fpm
      location ~ \.php$ {
          root           /var/www/command;
          fastcgi_pass   127.0.0.1:9002;
          fastcgi_index  index.php;
          #fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
          include        fastcgi_params;
          fastcgi_param SCRIPT_FILENAME $request_filename;
          fastcgi_read_timeout 3600;
      }
      } #end server2 section
  }
  </code></pre>
  
  <p><em>fastcgi_params</em></p>
  
  <pre><code>fastcgi_param  QUERY_STRING       $query_string;
  fastcgi_param  REQUEST_METHOD     $request_method;
  fastcgi_param  CONTENT_TYPE       $content_type;
  fastcgi_param  CONTENT_LENGTH     $content_length;
  
  fastcgi_param  SCRIPT_NAME        $fastcgi_script_name;
  fastcgi_param  REQUEST_URI        $request_uri;
  fastcgi_param  DOCUMENT_URI       $document_uri;
  fastcgi_param  DOCUMENT_ROOT      $document_root;
  fastcgi_param  SERVER_PROTOCOL    $server_protocol;
  fastcgi_param  HTTPS              $https if_not_empty;
  
  fastcgi_param  GATEWAY_INTERFACE  CGI/1.1;
  fastcgi_param  SERVER_SOFTWARE    nginx/$nginx_version;
  
  fastcgi_param  REMOTE_ADDR        $remote_addr;
  fastcgi_param  REMOTE_PORT        $remote_port;
  fastcgi_param  SERVER_ADDR        $server_addr;
  fastcgi_param  SERVER_PORT        $server_port;
  fastcgi_param  SERVER_NAME        $server_name;
  
  # PHP only, required if PHP was built with --enable-force-cgi-redirect
  fastcgi_param  REDIRECT_STATUS    200;
  </code></pre>
  
  <p><strong>UPDATE</strong></p>
  
  <p>It seems that the caching is already happening in the fastcgi server. This is from the nginx error log (the messages are bogus but do indicate that the php file is not the current one):</p>
  
  <pre><code>2015/08/07 12:08:51 [error] 4050#0: *127 FastCGI sent in stderr: "PHP message: PHP Fatal error:  Class 'getID3' not found in /var/www/cover2.php on line 8" while reading response header from upstream, client: 192.168.0.66, server: , request: "GET /cover2.php HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "192.168.0.35"
  2015/08/07 12:09:08 [error] 4050#0: *127 FastCGI sent in stderr: "PHP message: PHP Fatal error:  Class 'getID3' not found in /var/www/cover2.php on line 8" while reading response header from upstream, client: 192.168.0.66, server: , request: "GET /cover2.php HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "192.168.0.35"
  </code></pre>