Forum Moderators: coopster

Message Too Old, No Replies

PHP slow while running on localhost

         

NickMNS

2:36 am on Oct 9, 2022 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I'm trying to run a web-page built with PHP on my localhost but the page is loading really slow, it takes like 5 to 10 seconds to load, which makes no-sense. I'm certain that this is an Apache configuration problem but since I have no experience with PHP I have no idea how resolve it. I checked the PHP logs everything appears fine, the Apache log is also good it show the requests the requests returning 200 status.

The other issue I have, which leads me to believe that this is configuration issue is that to get the page I need use the url: localhost/index.php?/path.html instead of the expected localhost/path.html.

Any help would be appreciated.

Dimitri

1:04 pm on Oct 11, 2022 (gmt 0)

WebmasterWorld Senior Member 5+ Year Member Top Contributors Of The Month



Does your localhost run under Windows, or Linux?

robzilla

4:46 pm on Oct 11, 2022 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



So path.html is actually a PHP page, with the URI rewritten to path.html?

With your Network tab open in Developer Tools, can you confirm most of the time is taken fetching the script? Or is it something else, e.g. setting up the connection?

Does it only happen when you load a PHP script or also other files (e.g. static)?

Try 127.0.0.1 instead of localhost?

NickMNS

3:37 am on Oct 12, 2022 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Thanks for the input. I started to poking around a little more while trying to provide answers to you, and discovered that there was a database request that I wasn't aware of on the page, and that request was to a sizable collection (table for you sql folks) but there was no index. I added the index and bam! like magic the page returns in milliseconds.

That's what happens when you work on code that someone else wrote initially. Not to mention the fact that I hate PHP with a passion. I really don't understand how people can be productive. What happened to separation of concerns, url parsing, db-requests, html, js, templating all in mixed into one big file. Aaargh!

Dimitri

9:54 am on Oct 12, 2022 (gmt 0)

WebmasterWorld Senior Member 5+ Year Member Top Contributors Of The Month



into one big file

This is bad or amateur programmers, who are putting everything in the same file.