Re: [PHP] load the PHP script last on the page
I agree with Chris' method, but if you don't have cron, then what I do is a page-based cache. Since weather does not change with every page hit, you could store the parsed page inside a database, or even write it to a flat file, so if the page is hit 100 times an hour, and you do an hourly refresh on the cached version, you only get 1 slow page per hour, instead of 100. if the page gets hit 1000 times... you get the idea. You could check timestamps of the file (using file based caching) or add a timestamp field in your sql table. This sort of caching mechanism is used quite extensively on large sites, but it's easy enough to implement for smaller sites too. Of course, what you're doing is totally illegal, unless you have an agreement with msn to scrape their site g I know we don't like microsoft, but the law's the law ;-) Chris W. Parker [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] DougD mailto:[EMAIL PROTECTED] on Thursday, July 31, 2003 11:18 AM said: If it were possible I want the include to occur after the rest of the page is loaded. Maybe instead of including the file that does the processing and waiting forever for it to finish, you might consider setting up that same page as a cron job and have it create another page on your sever that you can quickly read/parse into your web page. You could have the cron job run every 1/2/3/4/5/10/15 minutes depending on how accurate it needs to be. Each time the page is loaded by the browser the server will grab the latest version and display it. hth, Chris. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] load the PHP script last on the page
I have a page with a particular PHP section that takes quite a time to load. Is there a way I can delay that script to run after everything else has loaded. I suppose it may need to use Javascript Thanks - appreciate your insights. -Doug -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] load the PHP script last on the page
[snip] I have a page with a particular PHP section that takes quite a time to load. Is there a way I can delay that script to run after everything else has loaded. I suppose it may need to use Javascript [/snip] For any insight to take place we would need to see the code. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] load the PHP script last on the page
Sure. It is pretty basic stuff. I have the following ?php include (weather/block.php); ? inserted in the middle of an HTML document to pull in the current weather. It delays the loading of the rest of the page too much as it queries to www.msn.com to pull weather data and then complete the script. If it were possible I want the include to occur after the rest of the page is loaded. Does that help? Jay Blanchard [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] [snip] I have a page with a particular PHP section that takes quite a time to load. Is there a way I can delay that script to run after everything else has loaded. I suppose it may need to use Javascript [/snip] For any insight to take place we would need to see the code. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] load the PHP script last on the page
DougD wrote: I have a page with a particular PHP section that takes quite a time to load. Is there a way I can delay that script to run after everything else has loaded. I suppose it may need to use Javascript You could use register_shutdown_function() to execute the code, providing you don't need any output sent to the browser. Do some testing as to whether PHP still waits for that function to finish or not, but I don't think it does. -- ---John Holmes... Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/ PHP|Architect: A magazine for PHP Professionals www.phparch.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] load the PHP script last on the page
DougD wrote: Sure. It is pretty basic stuff. I have the following ?php include (weather/block.php); ? inserted in the middle of an HTML document to pull in the current weather. It delays the loading of the rest of the page too much as it queries to www.msn.com to pull weather data and then complete the script. If it were possible I want the include to occur after the rest of the page is loaded. Does that help? Ignoring the probably copyright violations your committing, how are you going to display the weather if you include the page after it's loaded? THe page is done, then... -- ---John Holmes... Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/ PHP|Architect: A magazine for PHP Professionals www.phparch.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] load the PHP script last on the page
DougD mailto:[EMAIL PROTECTED] on Thursday, July 31, 2003 11:18 AM said: If it were possible I want the include to occur after the rest of the page is loaded. Maybe instead of including the file that does the processing and waiting forever for it to finish, you might consider setting up that same page as a cron job and have it create another page on your sever that you can quickly read/parse into your web page. You could have the cron job run every 1/2/3/4/5/10/15 minutes depending on how accurate it needs to be. Each time the page is loaded by the browser the server will grab the latest version and display it. hth, Chris. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] load the PHP script last on the page
...or use flush() just before that piece of code, if that's the case (if you don't need its output to complete the page). The page will be sent, the browser will remain in the page in progress state until the whole script is done, but that shouldn't bother your users, since they have the whole page to look at by that time. Bogdan John W. Holmes wrote: DougD wrote: I have a page with a particular PHP section that takes quite a time to load. Is there a way I can delay that script to run after everything else has loaded. I suppose it may need to use Javascript You could use register_shutdown_function() to execute the code, providing you don't need any output sent to the browser. Do some testing as to whether PHP still waits for that function to finish or not, but I don't think it does. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php