I'm currently working on a project where the client (a sales company) has a complex tracking system in place. In addition, they have a large amount of traffic and so the 20+ MySQL SELECT queries on every page are killing the server.
They've just installed Zend Performance Suite (ZPS) to cache the pages and the increase in performance is great.
However, they still need to log the clicks on every unique visit and store the referer information - which is passed in the query string from the referer i.e. http://www.test.com?ref=ga
The Zend Performance suite allows for the detection of cookies to determine whether or not to show a cached page.
I've tried several methods and am in desperate need of help.
- I tried using PHP to set a cookie - this is fine in principle - the user visits the page - is a cookie set? : NO - ZPS shows a dynamic page and logs the click and stores the referer. From then on, while the cookie exists a cached page is displayed due to the ZPS detecting a cookie is present with the 'referer' value set.
An issue with this solution is that the HTTP-Header information to set the cookie is cached by the ZPS - as a result the value of the 'referer' cookie is constantly updated - resetting it to the default value of 'noref'.
A colleague has mentionend using Javascript to set the cookie - as it will execute on every page (regardless of caching)
By using a 1x1 pixel image I could call a PHP script to execute (if required)
If the cookie isn't set : set the cookie - call PHP using JS image
If the referer value in the cookie doesn't match : update the cookie - call PHP using JS image
I know this is long winded but It's quite a complex process.
If you've used the ZPS or the JavaScript method outlined any feedback would really help. Finally, any help (no matter how small) would be greatly appreciated.
Cheers,
Paul