On one of my class-based sites, everything is controlled via the index.php
page, and every page is its own class
that gets called via that index page.
In one of those classes lies both the logged-in and logged-out header that gets called for every page of the site, both of which make a call for an Ad
that appears at the top of the site.
The problem is that whenever there is a redirect on a page, it doesn't happen until the class for that page gets called, which happens after the header has already been called, which means that an ad call was made for an ad that was never seen since the page ended in a redirect.
This negatively impacts the performance of the ads since it lowers the Click-through Rate (CTR) of the ads.
How can I ensure an Ad call is not made when a page ends up in a redirect, if there is no way to know the page ended up redirecting until the class for that page is loaded?
The only "outside-the-box" solution I can think of is to somehow use the output buffer to first load the class for that page, and then somehow append the header to the start of the buffer if it makes it to that point with no redirect, but I have no idea if that would work or how you would even do that.
Any ideas?
EDIT:
To clarify, the Redirects are already done via the HTTP header, and all output is currently being buffered. However, each page can have it's own reasons for redirecting, so that's why it's controlled by each page. For example, one page takes care of sending messages, and when a message is sent, it redirects the user back to their inbox after saving the message to the Database. On another page, logged-out users aren't allowed, so that particular page checks to see if a user is logged-in, and if not, redirects them to the login page.
However, it seems that even with full output buffering enabled and with the redirects being done via the header() function inside individual class pages, the buffering STILL does an Ad call before running the header redirect.