Jump to content

Page Optimization


random1

Recommended Posts

Hey All,

 

I'm looking for effective methods of optimizing pages. i.e. What are the actions that should take place on page load and on page exit?

 

* Garbage collection

* unsetting of variables

* Clearing of objects from memory

* Server Status etc?

Link to comment
Share on other sites

* Garbage Collection - PHP takes care of this, but putting __destruct methods in your classes will also help.

* unsetting of variables - You should unset any arrays, particularly if they are large

* Clearing of objects from memory - PHP will clean this up, but remember to do clean-ups in your destructor

* Server side status - not sure what you would want to monitor here

 

The bottom line: invest time into learning how to code well.  Any idiot can write code in PHP, but not everyone can code efficiently.  If you write code well, you shouldn't have to worry about the above.

 

You can also look at using a PHP framework which will automate some of the above.  Some frameworks also include page caching which will make your pages re-use database queries more effectively.

Link to comment
Share on other sites

Any idiot can write code in PHP, but not everyone can code efficiently.

 

That idiot may be me, you or alot others. If i cant write code efficiently, it means im an idiot? Anyone instead of any idiot could have been alot more appropriate.

Link to comment
Share on other sites

random1, there are many different forms of optimization -

http://en.wikipedia.org/wiki/Optimization_(computer_science)

 

You can optimize code to use fewer resources. You can optimize code to execute quicker. You can optimize code to be general purpose and independent of the type and amount of data it operates on. You can optimize code to be version/platform independent. Often these goals are mutually exclusive. You need to pick the one you want most.

 

But optimizing code means to change what it is doing during its' execution. This has little to do with when a page loads (unless you are creating unnecessary variables/objects and your goal is to optimize resources) and it has nothing to do with what you do on a page exit in php as all resources used by a script are destroyed when the script ends (see Daniel0's post.)

 

What you do to optimize any piece of code is dependent on what it is doing now (it might be as optimized as it can be) and on what optimization goal you are trying to achieve.

 

Your question is fairly general. Do you have a specific problem that is occurring you are trying to solve? Since optimization is highly situational, it is not really possible to give a specific list of things to do unless you have a specific problem or goal and a specific piece of code you want help with.

Link to comment
Share on other sites

Any idiot can write code in PHP, but not everyone can code efficiently.

 

That idiot may be me, you or alot others. If i cant write code efficiently, it means im an idiot? Anyone instead of any idiot could have been alot more appropriate.

 

Calm down. AP81's sentence doesn't actually imply that if you can't code efficiently then you are an idiot.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.