WordPress website uses mPDF. Function WriteHTML() always takes exactly 4 minutes when website runs on server. On my computer it takes one second. No error messages.
On some subsites is used mPDF to generate documents. One week ago it worked fast. Severals days ago it stoped working and subsites with mPDF started to give ‘500’ Internal error. I’ve increased execution time from 30 to 300 second and now no errors. But every single subsite with mPDF requires exactly 4 minutes to open. I’ve checked: function WriteHTML() uses all this time.
Copy of this site works well on my computer. Subsites with mPDF need just a second to open.
PDFs are small, max 150kb.
Server is:
Apache 2.4.6;
PHP 5.6.40;
mPDF 5.7;
Wordpress 4.9.10
PDF is generated by single-custom_post_type.php
(Yes, I know that PHP and mPDF are old, but it is not my website and I can’t explain it to owner. Also he has a lot of PHP scripts which doesn’t work with 7.0.)
After dissabling plugins, changing PHP version, clearing WordPress cache nothing change. I guess it is something with server config or protection. Owner claims that he didn’t change anything during several months.
2
Answers
I've found solution.
Problem was with path to images. Server was stop mPDF script when he tried to get images by using web url (eg. www.my-page.com/wp-content/image.jpg).
Instead of this now I use absolute path on disk (eg. home/public_html/wp-content/image.jpg).
Another solution I found, (still doesn’t answer the question of why this occurred) is to edit your host file on your server and resolve yourself ex.
127.0.0.1 nameofsite.com
This allows you to use url instead of absolute path. Found this was needed after I ssh in to my server and tried to curl my image and received no response.