I understand that the libraries and base classes & controllers get loaded when the client makes a request.
For example:
- user visits example.com
- index.php executes and loads class/library instances
- instances assigned to base controller (super class)
- the local controller (default) is called and then loads the view using available resources.
Now, because HTTP is stateless – does that mean if a user clicks , say, a button, all the objects have to be reloaded? If so, what impact does this have on performance?
Thanks!
It depends on whether the button sends another HTTP request. Yes, every autoloaded library will be “reloaded” with every request. That’s more of a PHP thing than anything else (nodejs or java-based servers aren’t like that).
If you’re blindly loading every library on every request–yes, that will negatively impact performance. If you’re loading them in the controller actions that need them, it’s much better. You might consider caching some of the objects in the database or memcached (preferred) if it gets to be a big problem. Until then, do whatever is quickest to develop.
Optimizing your time is the best performance boost you can get in the early stages.