Random image PHP scripts failing in Safari?

Discussion in 'Web Design and Development' started by lucidmedia, Aug 13, 2009.

  1. lucidmedia macrumors 6502a

    Joined:
    Oct 13, 2008
    Location:
    Wellington, New Zealand
    #1
    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...
     
  2. Cerebrus' Maw macrumors 6502

    Joined:
    Mar 9, 2008
    Location:
    Brisbane, Australia
    #2
    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?
     
  3. lucidmedia thread starter macrumors 6502a

    Joined:
    Oct 13, 2008
    Location:
    Wellington, New Zealand
    #3
    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...
     
  4. Cerebrus' Maw macrumors 6502

    Joined:
    Mar 9, 2008
    Location:
    Brisbane, Australia
    #4
    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.
     
  5. SrWebDeveloper macrumors 68000

    SrWebDeveloper

    Joined:
    Dec 7, 2007
    Location:
    Alexandria, VA, USA
    #5
    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
     
  6. lucidmedia thread starter macrumors 6502a

    Joined:
    Oct 13, 2008
    Location:
    Wellington, New Zealand
    #6
    Thanks all!

    I will do the above and post the results tonight...
     
  7. lucidmedia thread starter macrumors 6502a

    Joined:
    Oct 13, 2008
    Location:
    Wellington, New Zealand
    #7
    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.
     

Share This Page