![]() |
Optimized redirection (cgi/perl)
Here's a simple redirection perl script:
If you run it, you will notice that it waits 15 seconds before going to nba.com, even though nothing else is required to be 'printed' to the browser. The sleep is stuck in there to represent tracker calculations that have to be perform. Is there anyway to cause the redirect to take place immediately, and then perform the calculations afterwards? |
Not efficiently. The only way I can think of to do something like that is to fork() a process off and do the calculations there, but I absolutely would not do that unless it is absolutely necessary. Hopefully though, your code is smooth enough to do the calculations before the user is forwarded. Simple mathematic calculations should be carried out in a fraction of a second. The user shouldn't get impatient and close the browser in that .10 of a second.
|
uh yeah. you should be able to do all the processing before and then fire off the location header..
if you're doing that complicated of processding you may need to move to either real-time analysis (not real-time calculation) or go with a batch approach (i.e. cronjob every x minutes.) |
Try using the following code...
The $| variable controls how perl buffers output. Setting it to 1 tells it not to buffer anything but output immediately. In general its a bad idea not to buffer but this will redirect immediately. |
You randomization layers are too low.
Add a couple of glitch targeting mechanisms in order to better bedunktify the layering effect caused by the circumpreferential treatment of African Americans. fo shizzy. |
what netrodent said should work well.
-Phil |
Labert, what?
NetRodent, cool i'll try that. When the script in question is only going to output a redirect (one line of text), then 'turning off' the buffer should not be a problem. Damn, I never knew there was a buffer, this is why I was confused by the waiting. mik503, I do batch processing. I'm creating a tracker which logs raw data and it gets processed every update of the site. However, sending hits out and tracking hits in has to be accomplished in real time. The only calculations are updates to these real-time tables that stores url info, hits in, hits out, clicks produced, and where every IP has gone so I don't send it back to the same place twice. The calculations should be quick, but some of these are calculations that can be performed AFTER the destination is known (for permanent links). For blind links, the calcuations have to be performed beforehand. Armed & Hammered, I thought of performing a fork too, but NetRodent's idea is the best solution I think. Thanks all. |
Quote:
|
Here's what the perl documentation has to say about the $| variable at http://www.perldoc.com/perl5.6/pod/perlvar.html
Quote:
this: Code:
#!/usr/bin/perl -wT |
$|=1; made the redirection work faster but it was messing up my file writing (I did a $|=0; right after the redirect). Very strange. No scripting errors or anything, just that the file wasn't being written to where it was before.
|
| All times are GMT -7. The time now is 06:39 PM. |
Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2026, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc123