Browsing articles tagged with " speed tweak"

Speeding Up Web Sites with Flushing [PHP Speed Tweak]

Though, you should be careful when using it because it may or may not be helpful, depending on your application.

When a client requests a php (or any other server-side page) the server parses the whole page, then sends the resulting code to the client when it’s finished. Once the client receives the page, it can begin fetching images, or whatever media is on the page.

Using the following flush code could speed up the process for the client:

< ?php flush(); ?>

Be sure to remove the space between the right angled bracket “<” and the question mark “?”.

When the server encounters this tag, it will immediately send everything it’s already processed to the client before continuing on the rest of the page. For example, I use this code on another site right after the 3 codes for the 3 random header images are processed. This way, the client can begin fetching the images while the server processes and sends the rest of the page, which is mostly text.

Ultimately, we’re talking about milliseconds here, but its hundreds of milliseconds we might be shaving off. Again, with the site I mentioned above, it seems that by time the header images have loaded, the rest of the web site has completed it’s load. Not only did this save time for the user, but it gives the appearance that everything loaded at once rather than the page appearing with the header images appearing a few moments later.

Code responsibly.