I am on a shared server (Siteground), and since my WordPress PHP script takes more than 30 seconds, it returns a 504 Gateway timeout.
Will my query run and complete if it doesn't encounter a further error?
Edit: I asked why I received this error to my hosting team, here the Siteground Hosting expert explained the issue as follows:
We use both Apache + Nginx on all our servers. Apache is used for main web service, while the Nginx is used as a reverse-proxy and distribute cache. When the response cannot be served from cache (usually this refers to dynamic content) a request from Nginx is done towards Apache. This when Apache is processing the request, forwards it to your website and according to the PHP logic MySQL queries can be done or other data fetched. When this process takes too long and Apache does not return the response in a timely manner to Nginx you will see this error. In short Apache cannot server the request since the application did completed the process within the allowed time. This also means that the initiated process most probably did not completed fully and some data / actions might have been saved / executed.
The expert says that "initiated process most probably not completed fully"
,
More Details on my scenario: My script adds woocommerce products with variations using wp_insert_post
method to my wordpress website. After products added, it displays the images of newly added products.
When I add 1 product (40 variations), it completes and displays the product image. When I add 6 products (240 variations), I receive error directly in my browser.
So to further test this issue, I modified my code and re-wrote it using ajax and added a process bar like system. (Which increments a number for each variation).
After I run the code for 1 product (with 40 variations), the process number increases to 40, and it displays the product image.
When I run my code for 6 product, the process number increases to 240, but it doesn't display anything, and when I check, it receives an 504 error. (jQuery.Ajax
function error section)
So this makes me think that the query runs even it timeouts, but still I am not able to be sure, and looking for details behing 504 gateway timeout error since there are no good documentation on this.