Truncated or invalid FastCGI responses
When setting up an Nginx frontend for a website that heavily relies on AJAX (Asynchronous JavaScript and XML), along with a FastCGI backend such as PHP, you may run into different sorts of problems. If your server returns truncated AJAX responses, invalid JSON values, or even empty responses, you may want to check your configuration for the following elements:
- Have you set up a writable directory for FastCGI temporary files? Make sure to do so via the
fastcgi_temp_path
directive. - If
fastcgi_buffering
is set tooff
, all FastCGI responses are forwarded to the client synchronously, in chunks of a certain size (determined byfastcgi_buffer_size
). - In some cases, increasing the size and number of buffers allocated to storing FastCGI responses prevents responses from getting truncated. For example, use
fastcgi_buffers 256 8k;
for 256 buffers of 8 kilobytes each.