www.webdeveloper.com
Results 1 to 11 of 11

Thread: Cache Buster

  1. #1
    Join Date
    Jun 2007
    Location
    Orlando, FL
    Posts
    66

    Cache Buster

    Hi everyone,

    I apologise if this isn't in the right area of the forum, but i'm fairly new here.

    Anywho...

    This is in regards to an advertising segment on my site. Analysisng proper impressions (i've been told) can be shot somewhat by caches. So i was referred to a cache buster, placed on an 'a href'?

    Is this right? Will adding a 'cache buster' be 'damaging' in anyway? I understand it will take longer to load than a cached part would, but I wouldn't want it on the whole site, just the advert. It's so the ad can be properly judged on impressions (cached ad's don't show up as impressions - thus giving an improper read out). Can you put it on one thing, is this ok?

    Also, if it's fine to do - to be honest i'm not really sure how to go about doing it. I can't find an example of it done in any code (or one that i've realised). Apparently you have to use a 'random number string' (not a date stamp), as it's more effective if multiple users are clicking the advert. How do you add the 'random number string' to the 'a href'. Do you simply add to the end or something (e.g. <a href = "http://www.site.com/%%randomnumberstring%%">Link</a>?) I really don't know.

    Any help or example would be greatly appreciated.

    Thanks for your help,
    Rich.

  2. #2
    Join Date
    Nov 2003
    Location
    Jerryville, Tejas
    Posts
    11,715
    More like

    http://www.site.com/page.html?parm={timestamp}
    "Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." Brian W. Kernighan

  3. #3
    Join Date
    Jun 2007
    Location
    Orlando, FL
    Posts
    66
    I was told datestamps were bad becuase they could asign the same 'random' string to multiple people if they all clicked an ad at the same time. Why this is bad, i don't know! lol. I think it would send wrong information to all but one of the multiple people?

    Lets backtrack here - i assume what you wrote was a datestamp as it says 'timestamp' somehwhere in there, but 2 be honest - i don't know. They may just look similar but refer to completley different things. If that's the case, Is what you've wrote there a 'random number string'? Or is it indeed a datestamp? If it is a datestamp, how would you put a random number string there instead of the that?

    Thanks, Rich.

  4. #4
    Join Date
    Mar 2005
    Location
    Sydney, Australia
    Posts
    7,974
    A date/time stamp will stop the page from caching since the same person will not request the page more than once at the same time. It doesn't matter if someone else does as that is a different computer. Unlikely that two people would click the link at the exact same millisecond in any case. A random string may duplicate itself defeating the purpose of adding it to the link.
    Stephen

  5. #5
    Join Date
    Jun 2007
    Location
    Orlando, FL
    Posts
    66
    That's interesting. I've seen a few mention otherwise. Personally, I have no idea so I undertook a lil' mission to find out (if cache busters were benficial to my ad's).

    Here's one of the site's i found addressing the date stamp vs. random number issue. you guys will be able to make better of if than me i'm sure;

    Cache Buster Info

    So, it's absolultley fine to do this on your ad's url's then? There's no hidden nuisances are anything? The only thing i can see myself is that obviously it'd load a bit slower than a cache of the ad because it's essentially new, but that's fine (kinda the point). Can anyone see any other potential problem's with using them?

    Thanks,
    Rich.

  6. #6
    Join Date
    Nov 2003
    Location
    Jerryville, Tejas
    Posts
    11,715
    I didn't say date, I said timestamp. Timestamps are generated to the highest partial second resolution of the code doing the generation so unless you're getting thousands of requests per second that won't be an issue. Also, the characteristic of the value that "breaks the cache" is that it is different from the value previously submitted by the same browser. In that case even one second granularity will not matter.
    "Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." Brian W. Kernighan

  7. #7
    Join Date
    Jun 2007
    Location
    Orlando, FL
    Posts
    66
    thanks ray326.

    I wasn't sure being unfamiliar to it all whether a 'timestamp' was a 'datestamp' or not (time being similar to date) so i thought it was worth asking.

    So all you do is put that code on the end of the address and it'll generate all fine?

    Just to make clear (so i don't end up doing it wrong and annoying everyone some more!) - do you add this code (for example):

    '/page.html?parm={timestamp}'

    onto the end of the 'a href' (for example):

    'http://www.site.com'

    to make this: 'www.site.com/page.html?parm={timestamp} ' ?

    Thanks guys,
    Rich.

    PS: Just so i know aswell, is the above code a 'random number string', or is it something else again?
    Last edited by RTP; 06-26-2007 at 03:08 PM.

  8. #8
    Join Date
    Nov 2003
    Location
    Jerryville, Tejas
    Posts
    11,715
    It's random enough. Obviously (to me at least but maybe to no one else) the string "{timestamp}" represents the output of a bit of code that depends on the server side technology (ASP, PHP, Java, ...).
    "Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." Brian W. Kernighan

  9. #9
    Join Date
    Jun 2007
    Posts
    112
    You could do this in several ways. For example, in PHP, you'd use something like this:
    PHP Code:
    <a href="http://www.example.com/ad.html?parm=<?=time()?>">Link</a>
    You could also, maybe, do this in Javascript (I don't know much JS, but here's my attempt).

    HTML Code:
    <div id="thead"><a href="http://www.example.com/ad.html">Link</a></div>
    
    <script language="javascript">
    document.getEementById("thead").innerHTML = 'a href="http://www.example.com/ad.html?parm=' + getTime() + '">Link</a>';
    </script>
    I'm sure that's a horrible way to do it, but it'd work, and it has the advantage of not requiring you to use PHP.

    Who's your webhost? PHP would be the best way to do this, if you can.

    And no, a timestamp isn't a random number. It's actually (in PHP) the number of seconds since 1970. Still, it doesn't need to be a random number. It just needs to change each time the link is clicked on.
    Last edited by bluestars; 06-27-2007 at 07:00 PM.

  10. #10
    Join Date
    Jun 2007
    Location
    Orlando, FL
    Posts
    66
    Hi,

    Thanks for the info there bluestars.

    Atm, i'm just developing the site, or rather, testing things that i've kinda 'storyboarded' to see if parts I've designed are actually feasable when it comes to actually making the code of the site (if that makes sense!). In other words, just in the preliminary stage of coding tests (well, tests for me as everything is fairly new!).

    I was told cache busting can obtimize ad analysis, so i thought it'd be worth implimenting.

    I'm using Dreamweaver 8 to put my site together (have Adobe Go Live but am much more familiar with Dreamweaver). So, as i'm completley unversed in PHP - does the PHP version code simply go in the 'coding' of the site in Dreamweaver, or do you have to do it someplace else/some other way? Would you have to have already got all the hosting and the like worked out b4 using this PHP, as my site like i said is still in test phase, not uploaded yet or anything (I have a domain name but no hosting secured as of yet).

    This may sound all so stupid, i'm not sure, but I'm fairly new to all this; and in truth have only heard of PHP - i have no real idea of what it does!

    Thanks guys for you patience and help.
    Rich.

  11. #11
    Join Date
    Jun 2007
    Posts
    112
    PHP is a server-side language. That means that the client won't ever see your code; they'll just see the output. If you find a host that supports PHP, you'd just have to name your page with a .php extension (so the server runs the PHP program on it) and then put the code in as you would normal html.

    But, testing it on your computer, the php will never get executed. So, if you get a webhost who supports it, just put that php in where ever you'd put HTML.

    Actually, use this. For some reason the shorthand hasn't been working for me lately.
    PHP Code:
    <?php echo time(); ?>

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles