I have a footer file which causes some pages on a site of mine to load slowly. I currently just have include('footer.inc'), is there a way to get the rest of the page to load first rather than having this footer file delay the loading of the whole page?
flush(); ob_flush(); include('footer.inc'); PHP: Should send your visitors everything up to the footer before processing the footer.
This could be an html related issue if you are using tables for your layout. Some browsers don't show the contents of a table until the whole of the html table and content has been loaded - sounds a bit daft. But if your whole page is a table then nothing shows until everything is loaded. it may be a simple case of stop using tables for layouts, or break up your page design into horizontal tables eg one for the header, one for the middle and one the footer. Or of course the post above works for me
Thinking about it, thats probably it - I will check it out, thanks for the suggtestion. I will also try the flush suggestion, thanks for that too!
Does your footer.inc include any Adsense, Adbrite or other ad hosting services. I've seen my pages take for ever to load waiting on the Adbrite ads to be displayed.
If you are making a remote connection to an ad service or any third party you may want to add ini_set (default_socket_timeout, "3"); before the connection is made. This means the maximum delay is 3 seconds before the attempt is aborted.
its sorted now, i just rearranged my tables so that everything before the footer loaded on the page without the need towaitfor the footer first. thanks.
dave: your time out setting is really valuable. I wasn't aware that could be done. If a timeout occurs, can you have the error message return something useful, like a locally stored banner ad? I'll research this on PHP.net, but if you have any example code I would appreciate it.
Sure, use this: ini_set (default_socket_timeout, "3"); error_reporting(0); $some_url="http://www.domain.com"; $filestring=file_get_contents("$some_url") ; if(!$filestring){ echo"file could not be opened"; } else { echo"$filestring"; } PHP:
Hehe.. speaking of which, please refer to "<DIV> vs <TABLE>" and remember to cast your vote. [edit] By the way Dave487: Thx for the example, might come in handy.[/edit]
Last my my site was slow to snail. After playing with the code, i realise it is due to JAVASCRIPT from clicksor. Watch out for javascript!
Hard to belive but someone red repped me for this, a number of weeks after the thread starter green repped me for solving his problem. Silly Billies Come on people. If someones knowledge is flawed then share with everyone else in the forum, that's what threads are for....