• Resolved chewru

    (@chewru)


    I am running WP-SuperCache and a banner ad rotator that is using a simple php call to pull a given banner from ones listed in a text file. The call is made in the header.php file.

    I’ve noticed that WP-SuperCache does such a great job at caching that it doesnt really allow my banner rotator to actually randomly rotate. Because WP-SuperCache delivers a static HTML copy of a once-generated page, whatever banner is picked once stays until the cache is cleared.

    That’s not great for my advertising efforts. Due to randomness, I noticed some of my banners weren’t even showing at all because it’s a straight 1/5 shot each 100 requests — which might be a half of a day for my site.

    I can’t be the only one who wants to both cache the nuts and bolts of the site but still have some ability to let my ads randomly generate.

    Any ideas?

Viewing 14 replies - 1 through 14 (of 14 total)
  • Moderator Samuel Wood (Otto)

    (@otto42)

    www.ads-software.com Admin

    Don’t use a PHP based rotator, or don’t use Super-Cache.

    Sorry, no other solution. The whole point of Super-Cache is to not have any PHP run at all. To make the site static.

    If you want something on the page that is not static, then either do it in the browser with a javascript based rotator, or don’t use Super-Cache.

    Thread Starter chewru

    (@chewru)

    Otto, thanks! Any suggestions on a java-based ad rotator? All the ones I can find here are calling PHP. Any downside to using Java besides that a few browsers might have it disabled? I imagine it’s considerably slower than PHP?

    I was thinking — can I just try to fit the call in the index template file? After all, that isnt entirely static – it has to display the newest posts? I tried putting one of the PHP calls prior to the get_header function, but although the ads loaded, my sidebars didnt for some reason.

    Thanks for your help. You do a lot for the WordPress community and we thank you!

    Moderator Samuel Wood (Otto)

    (@otto42)

    www.ads-software.com Admin

    A Super Cached page is *entirely* static. Moving the code around won’t help you a bit.

    Also, Javascript is not really all that slow. I mean, it’s just picking a random image from a list. Not hard.

    As far as what one to use, heck, Google for it. There’s millions of them. You can probably write one yourself.
    https://www.google.com/search?q=javascript+image+rotator

    Thread Starter chewru

    (@chewru)

    That worked like a charm. Thanks! Here’s the code I ended up using. There’s a lot of others out there, like you said.

    <SCRIPT language=JavaScript>
    /*
     +---------------------------------------------------------+
     | Ad Simple                 Copyright www.YugDesign.com   |
     +---------------------------------------------------------+
     | This program may be used and hosted free of charge by   |
     |anyone for personal purpose as long as this copyright    |
     |notice remains intact.                                   |
     +---------------------------------------------------------+
    */
    
    var img_width = "468";
    var img_height = "60";
    var img_title = "Click Here";
    
    var ad=new Array()
    //insert here your images src
    ad[0]='https://www.site.com/image1';
    ad[1]='https://www.site.com/image2';
    ad[2]='https://www.site.com/image3';
    ad[3]='https://www.site.com/image4';
    ad[4]='https://www.site.com/image5';
    
    var links=new Array()
    //insert here your links
    links[0]='https://www.links1';
    links[1]='https://www.links2';
    links[2]='https://www.links3';
    links[3]='https://www.links4';
    links[4]='https://www.links5';
    
    var xy=Math.floor(Math.random()*ad.length);
    document.write('<a href="'+links[xy]+'" target="_blank"><img src="'+ad[xy]+'" width="'+img_width+'" height="'+img_height+'" alt="'+img_title+'"></a>');
    </SCRIPT>

    Alternatively you could use an iframe to call an ad-page on your server, and then add that url to the exceptions. This is suggested here (although with a different situation and outcome):
    https://www.ads-software.com/support/topic/182723
    In my case I have mixed image and flash banners rotating, so that’s what I’ll do.

    Thread Starter chewru

    (@chewru)

    matthias — this is a very interesting solution and certainly does let you have dynamic content from any ole’ HTML page, but my newest issue is that i’m trying to run this performancingads plugin that is calling PHP. the obvious solution is for *them* to just code a javascript version. still, im bitching and moaning and trying to find a workaround. lol.

    the iframe would work with the plugin if i made a wordpress-created page, but the problem with that is that it would load the WHOLE SITE in that iframe to enter the wordpress loop to get that page.

    if i make an ads.html file or something outside of wordpress, it would look right, but i’m fairly certain I couldnt then use it to call a wordpress plugin – as the HTML file is outside of wordpress and the call probably wouldnt make any sense to mysql.

    here’s my original post on it. if you have any ideas, it would be terrific. lots of people are making pretty decent money on this network so far.. and i’ve love to sign up.

    seriously — isnt pretty much everyone running some kind of cache? you think they’d consider that.

    https://www.ads-software.com/support/topic/194681?replies=1

    Can’t you add the URL to the plugin in the filtered-out URLs in the options of WP-Supercache ?

    Quoting the options inside WP Super Cache :

    Add here strings (not a filename) that forces a page not to be cached. For example, if your URLs include year and you dont want to cache last year posts, it’s enough to specify the year, i.e. ‘/2004/’. WP-Cache will search if that string is part of the URI and if so, it will not cache that page.

    I may have understood it wrong of course, but doesn’t that leave open the possibility that some elements inside a cache page will still need to be dynamically loaded, as long as their components depend on a blocked URL ?

    Thread Starter chewru

    (@chewru)

    sabinou – thanks for the help. unfortunately, i dont think it works like that. supercache can exclude a page (which I interpret to be a page in the WP loop) from being cached, but a direct path to a plugin is not a page in wordpress. the best real-life example i had with that exclusion feature is when I installed a WP-POLL on a certain page in wordpress which I called ‘polls’. I told supercache to exclude it, and voila, even tho the page was only a php call to the plugin, it wasnt cached and the results showed up instantly upon voting. in this situation, the ads section is hard-coded into a sidebar that is shown on every page. in php form, it’s becoming increasingly clear i can’t have the plugin work as-is AND still cache the content around it.

    that’s why javascript works perfect. since it’s client-side, it can’t generate a static set of code on the server-side. so it sends the cached pages and essentially says to the browser “you finish the rest”.

    the reality likely is that PerformancingAds just needs to write a javascript version. there’s a reason why google did that with adsense. it’s almost universally compatible with browsers and web platforms, doesnt need to touch your database, and will work with caching.

    i’ve written them a few emails. hopefully they’ll respond to one of them.

    Moderator Samuel Wood (Otto)

    (@otto42)

    www.ads-software.com Admin

    I’d need more information about how PerformancingAds works to give you a better solution. Could you give me a link to the PHP code they use or something?

    Edit: Scratch that, I found their plugin and am looking at it now. From what I can see, it just fetches some stuff from ads.*some-kind-of-id-code*.performancingads.com and displays it. That’s all it really does. Oh, it hits ping.performancingads.com once every 10 hits (randomly), but for the most part, that’s it. There’s absolutely no reason that this could not be done entirely with Javascript code as well.

    Moderator Samuel Wood (Otto)

    (@otto42)

    www.ads-software.com Admin

    Okay, using the perfads plugin, you can do this:

    1. Make a new PHP file somewhere. Call it “ad.php” or something. Put all the perfads php stuff in that same directory as the ad.php. There’s no need to configure it as a WordPress plugin.

    2. Put this in that new ad.php file:

    <?php
    include_once('perfads.php');
    perfads(REGION_ID);
    ?>

    Use your region ID, obviously.

    Then, you can include that ad.php in an iframe if you want. That might be suitable enough for now. Alternatively, you can use jQuery or any sort of javascript client code that will pull in and include that ad.php file.

    Thread Starter chewru

    (@chewru)

    wow. thanks! i’m going to try this right away!

    Thread Starter chewru

    (@chewru)

    Otto, here’s what I’ve experienced so far:

    a) the caching doesnt prevent new ads now. that’s terrific! when changing the number of my ads on their site from 2 to 4, it showed instantly on my site.

    b) the ads display, but when you click on the ‘advertise here’ button, it loads in the iframe and not in a new page. since there’s no href – is there something i can maybe pop in the php to make the click load in a new page?

    c) when i do click in, their site claims I have no regions of which to buy ads. i dont know if this is because of the way that we did the include or if there’s a glitch on their site. the URL generated looks correct compared to other advertisers. i did add the regionID they gave me to the included php. when i tried this a few days ago through the plugin, their site correctly showed the regions available and the cost immediately. i’ll see if this clears up in an hour or so.

    either way, i appreciate your help with this. there are others out there that have been trying to get this done outside of the plugin as well, so hopefully we’ll figure something out.

    EDIT: as a test i installed the plugin again, put in the region, and clicked through. it DID NOT display the regions/prices correctly, so i will chalk that up to their site for now. so if we can figure out how to make the click go to a full page, we should be good. =)

    Moderator Samuel Wood (Otto)

    (@otto42)

    www.ads-software.com Admin

    The only way I can tell you to make it load a full page is to not put it inside an iframe. Use some sort of javascript to load and include the HTML from that ad.php file instead.

    Thread Starter chewru

    (@chewru)

    RESOLVED: Enough emails to PerformancingAds did the trick! =)

    Here’s the code:

    <script type="text/javascript"
    src="https://ads1.performancingads.com/js/perfads.js?r=REGION_ID"></script>

    just replace your region id. thanks to all who weighed in!

Viewing 14 replies - 1 through 14 (of 14 total)
  • The topic ‘WP-SuperCache w/ Banner Ads’ is closed to new replies.