Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

lucidmedia

macrumors 6502a
Original poster
Oct 13, 2008
702
37
Wellington, New Zealand
Hi all,

Has anyone else had issues with PHP image randomizing scripts not working in safari?

I had originally used this one from A List Apart: http://www.alistapart.com/articles/randomizer/

and it works fine in all browsers, except my version of Safari (4.0.2)

I tried a few other random image scripts and they failed as well!

In safari, the first image loads up fine, but it does not rotate on page reload. If you close your session and start again, you get a new image.

Cache issue? Should I try to append the filename with a random timestamp, etc?

thanks in advance...
 
If you think its a caching issue, you can always tell the browser to not cache regardless including

Code:
<?php
 header("Cache-Control: no-cache, must-revalidate");
?>

in your php.

Any chance a link to your site?
 
If you think its a caching issue, you can always tell the browser to not cache regardless including

Code:
<?php
 header("Cache-Control: no-cache, must-revalidate");
?>

in your php.

Any chance a link to your site?

Thanks Cerebrus...

Unfortunately I can't link... the site is not yet live and is password protected... but the entire script I am using is on the a list apart site...

Its interesting that every script I have tried seems to have the same issue in safari.

I will give your suggestion a try, but don't want to shut down caching 100%

I have run into the same problem before when loading dynamic content into flash and had to append a random timestamp into the request. I may also try adding this...
 
Safari can indeed to odd things with dynamic content. I've ran into something similar when calling a php via Ajax. Basically the PHP program was a compressor for image files, that returned an id for the output image. Worked fine in Firefox, but on Safari it returned a 200 OK message each time, which was from the compressor itself, rather then the script.

I've heard it mentioned that safari can be quite slow to update such content, that basically it "trips" over itself. Solution maybe to actually put in a small time buffer from when the script returns and to when it actually displays.
 
Turn on the debugger in Safari via: Safari preferences > Advanced > Show Develop Menu in menu bar

Report what you see here in terms of errors.

If no error, as a test, choose from the Safari menu: Develop - User Agent - <any other windows client (Firerox or IE)> - some report Ajax or server side dynamic scripts start working when true. But that means a Safari bug beyond your control to resolve if the prior resolutions posted here do not work.

-jim
 
Hi Jim,

No errors are being flagged, and there is no result if the user agent is changed.

If I disable cache it starts working as expected... almost. Image refreshes are occasionally intermittent. I find that safari's cache is just "stickier" than the other browsers...

thanks for all your help.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.