Maximum execution time of 30 seconds exceeded

I searched for solutions on the internet but they mostly said that this was caused by slow database queries, however my app is slow even when I disconnect from the database.

I could change the execution time by changing max_execution_time in my php.ini but I don’t want to give it more time; I want it to load more quickly. No one will want to re-visit my web site if the pages load that slowly.

One site said that it could be re-creating the cache for every request and that I should change the file permissions on the tmp and log folders but I don’t see why changing the permissions would have an effect on caching and I was only able to allow sharing on my Windows xampp system anyway.

Disclaimer: I am not a web developer (go figure) so I can’t provide any info based from experience.

Use the Chrome dev tools to analyse your page. Press F12 and go to Lighthouse (last tab) and generate a report : mobile/desktop.

The dev tools can also display CPU loading times, overlapping actions and bottlenecks. Also use the Performance tab and record the loading time - both full-load ‘Ctrl+Shift+R’ and refresh ‘F5’. Note ironically the refresh is more relevant as full load only happens maybe once a day - but still it’ll give clues.

Both the browser and CakePHP have significant caching, so you don’t always know what is doing what for you (static css js & images is your browser cache, repeated queries and static forms is cake).

It may simply be images which are bigger than need be, or trailing variables on GET which force ignoring the cache (which is handy at times *cough*Google KMZs*cough*).

Even the Network tab in dev tools, very handy for tracking slow AJAX, iFrame, etc.

Then, you should be able to complete the sentence; my web page is slow because of ______, how can I make that quicker? :slight_smile:

Edit: If its slow before loading then use the CakePHP debug and stick in debugs of function name + date_time so you can see where in the PHP its stalling - specifically focus on before & after any preloaded queries.

I said that I disconnected the database and so I didn’t think it was related to that but on second thought I think it still executes the SQL queries even when I disconnect. I’m not sure.

Thanks, Jawfin. On my computer, pressing F12 turns on airplane mode. I selected Developer Tools in my Chrome browser but I didn’t see any of the tabs you mentioned. I’m going to read your post again later and see what I can understand. I’m not good at reading because I hear voices. I have a very low reading comprehension so I need to read and re-read.

The 30 second timeout wouldn’t likely be related to images or CSS or things like that loading slowly. It’s PHP that’s timing out, trying to do something. Is it all pages that do this, or just some? Does it matter if you’re logged in or not? If you create a very simple x.php in your webroot that just has <?= 'Test'; in it, how long does that take to load?

1 Like

Yup 99% chance its in your PHP. May even have a dead-loop, or at least poorly optimised code. Put in echos as Zuluru says - and I like to put in timings, and comment out chunks of heavy code, slowly re-introduce so you can find the bottlenecks. In fact, as Zuluru said, start with nothing but Hello World and work your way up!

Also, politely, learn how your laptop works! I would guess you have a HP and it’s got a function override that hijacks your function keys (I hate those things!) so that F12 has been repurposed.

You can also do Google searches on other ways to open the dev tools, which lead me to this article Chrome DevTools  |  Google Developers
because you will need a decent client-side debugger sooner or later!

Thanks for your replies, Zuluru and Jawfin.