I'm searching for a method to serve cached redirects (via filesystem). And So I might have a /cache/ folder with files like "google.txt" and taking advantage of file_put_contents() place 'http://www.google.com' in to the 'google.txt' file.

However , I wish to really track the ip's, sights, etc.. within the database, but I wish to redirect the consumer as rapidly as you possibly can. And So I have produced an easy flag function for use. Here's some pseudocode to higher illustrate:

if redirect_is_cached() //True if google.txt exists
   redirect_to_link() //actual redirect header(location:...)
   user_was_redirected_via_cache(TRUE) //STATIC: defaults to FALSE if no parameter is used.
   //No exit because I want to track data but database isn't loaded.

...

code snipped out...later on in the script.
...

db_connect(); //Now we can access the database

   if(user_was_redirected_via_cache()) { //TRUE since we flagged it earlier.
     track_redirect(); 
     exit();// Proper exit. We redirect user quickly, 
            // but continue script so we can track redirect.

   }
   else { continue with rest of script }

My questions are 1) performs this follow "guidelinesInch or perhaps is it type of hackish? and a pair of) Does the consumer get rerouted in the header() or even the exit()? When the user does not get rerouted until I really exit() the script...this really is type of pointless.

Just help.