I love the random banner graphic idea but it's not being random for me. When I navigate around the site, opening up pages to create a forum post, going into admin mode, etc, the graphic doesn't change eventhough I have 6 in the directory.

Now if I do a hard refresh it does change.

I navigated around this site:

http://www.signalkuppe.com/marinelli/

and it randomizes just great. What am I missing?

Thanks!

Comments

Lioz’s picture

well that's strange.
OS? Browser?

frazzle-1’s picture

IE7 and Firefox (latest). I use Windows XP.

The site is http://www.bringohiohome.com/ and there are 17 images in the directory.

Lioz’s picture

i just checked your site, everything is ok i can see the rotating banners
maybe a cache issue?

frazzle-1’s picture

Well, I'm puzzled.

Since I didn't know which cache you were referring to, I cleared out my cache in IE and the drupal cache (and all cache is turned off in drupal in any case) and it's still not rotating for me unless I do a hard refresh.

I just visited again:

http://www.signalkuppe.com/

and I click around and the banner rotates for me.

It doesn't seem to be my browser since it worls elsewhere but not on my site.
It doesn't seemt to be my site since it works for you but not for me.

What am I missing?

bitsize’s picture

I'm having the exact same issue.
On my local host: xampp, the banner rotates w/ every click in both ie7 and FF.
On my live host: unix (cpanel), the first banner loads but never changes. Only a hard refresh does the trick.
I don't have caching set for drupal at all.
Any suggestions?

Lioz’s picture

i think something on your host is blocking the banners.
any ideas?

dchapiesky’s picture

It is possible that you are experiencing memcache at your provider's internet gateway....

Internet
^
firewall
^
web server (Upstream server) <=====> memcache (gigabytes of memory)
^
virtual servers
^ ^
Your website | My Website
^ ^
mySQL | mySQL

Not a very good diagram but...

Your site is probably stored in a "virtual server" - meaning it is one of many sandboxes running on a single physical server. When a request comes in from the internet, it passes through their firewall and on to their primary webserver. It determines the location of your virtual server and passes the request on to your site. It keeps a connection open waiting for the page to return.

After the page (i.e. your banner) is returned, it passes the page back to you, AND stores it in memcache using the page URL as the key. The next time that url (www.mysite.com/images/mybanner.jpg) is requested, the memcache is checked with the url again as the key.

Your original banner is returned and your website never even get's to think about it long enough to rotate....

There are HTML tags to state that a page's content is "non-cachable"... that might be the way to go....

Daniel

(memcache actually kicks but... how would you like to have a hash database in 32 gigabytes of RAM?)

frazzle-1’s picture

So what are these HTML tags to make the page "non-cachable"?

Thanks!

dchapiesky’s picture

See: http://www.i18nguy.com/markup/metatags.html for description...
See: http://www.htmlgoodies.com/beyond/reference/article.php/3472881 for how to use it and caveats...

You should be able to modify page.tpl.php and insert the code in the appropriate place...

BTW - I am experiencing the same problem with IE7 and my local server.... So it seems it is the browser cache that is being funky...

I'm going to try this stuff myself and will let you know... but please try yourself also since I cannot promise when (today, tomorrow, next week) I can get to this.... I'm putting another pot of coffee on right now... so keep your fingers crossed...

Daniel

dchapiesky’s picture

FIXED (only two cups of coffee later...) !

See below for mod.

-------------------------------------
Research:

I found an even better description here:

http://www.mnot.net/cache_docs/#META

This link explains what is happening in the fix below...

-------------------------------------

Drill down to marinelli/img/banners and edit rotate.php

find the following code at the bottom of the file:

      $imageInfo = pathinfo($img);
        $contentType = 'Content-type: '.$extList[ $imageInfo['extension'] ];
        header ($contentType);
        readfile($img);

Now insert the following code between "header()" and "readfile()" :


/* dchapiesky - force caching of image to be turned off... */

        header( "Expires: Mon, 20 Dec 1998 01:00:00 GMT" );
        header( "Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT" );
        header( "Cache-Control: no-cache, must-revalidate" );
        header( "Pragma: no-cache" );

resulting in:

   $imageInfo = pathinfo($img);
        $contentType = 'Content-type: '.$extList[ $imageInfo['extension'] ];
        header ($contentType);

/* dchapiesky - force caching of image to be turned off... */
        header( "Expires: Mon, 20 Dec 1998 01:00:00 GMT" );
        header( "Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT" );
        header( "Cache-Control: no-cache, must-revalidate" );
        header( "Pragma: no-cache" );

        readfile($img);

--------------------

Click refresh and see the banners change....

Remember that the randomness is based on how many banners you have and does not guarantee that the same banner won't be served twice... in a random manner

Add more banners and the less likely you will see the same twice.

The code above tells your browser, any internet caches in between, and the site server that the image being served should not be cached. It also says that the date the image expired and should be refreshed is in 1998.

The Expires line seems to be directed towards internet caches on the actual Internet backbone.
The Cache Control line seems to be directed at your web server such as apache... (which needs modules loaded to understand it...)
The Pragma line seems to be directed at browsers which understand it...

Try this out. I'd love to know if it also works for you.... (be sure to add more banners [I tested with only three banners and checked my network connection with ethereal - the banners were requested by the browser each time - so the statistics of the issue were confirmed as well as the caching...])

Daniel

Lioz’s picture

great post dchapiesky!
i'll put this patch in the next release!

frazzle-1’s picture

Works for me!

I had to do one hard refresh (to load the new PHP code) and then it began to work for me.

Thanks!

frazzle-1’s picture

Status: Active » Fixed
bitsize’s picture

Perfect! Thanks so much for the great post.

Lioz’s picture

fixed in 6x-1.7!

Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.

douglaslopezt’s picture

Version: 6.x-1.5 » 5.x-2.0
Priority: Normal » Minor
Status: Closed (fixed) » Fixed

thanks for the fix, it works good

Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.