Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

I'm developing a mobile website and am using an iPhone for testing it. One of the .jpgs used was faulty and displayed as a black rectangle in the iPhone's Safari browser. The code was then changed and there is now a .png image instead. For some reason even after clearing Safaris cache that image is still black, and I need a new phone that has never visited the website before in order to display it correctly.

Why is that happening and how can I fix it?

share|improve this question
add comment

2 Answers 2

Sounds like an iPhone bug/feature where it will cache some images (and not clear them properly).

The fix seems to be to put a random number in a query string after the images on your site.

eg picture1.png?2011242424

Some web frameworks will do this automatically (eg rails). Otherwise you could do this on just the affected image and see if it fixes it.

share|improve this answer
add comment

You can try browsing to the image itself, refreshing that page - that usually clears the cache for the image.

However best practice in web development is to follow @RobZolkos 's advice about putting a number string after the image src. When you change the image, you change the number, which forces it to load again. A little off topic, but check out HTML5 Boilerplate's cachebusting which does this for you automatically in the build script.

share|improve this answer
    
The problem is Safari doesn't even notice that the string changed. The src is still ending in *.jpg even though the server delivers it as *.png –  Lars Apr 18 '11 at 12:33
    
@Lars Have you checked that it works on a desktop browser? And are you definitely going to exactly the same URL? If you know it's working on the desktop, email the URL to your iPhone and click on the link. Just checking the obvious, because it sounds like a server problem rather than an iPhone one. –  Blowski Apr 18 '11 at 12:43
    
Yes I did check it in Firefox with User Agent Switcher and it works fine there. The URL is definitely the same. But maybe it could be the Drupal that is used for that site? –  Lars Apr 18 '11 at 12:48
    
Ah yes... didn't think of that. Clear Drupal's cache. It could be that you are not logged in on Drupal, so it is showing you a cached version of the page. Go to admin/settings/performance - clear cache is at the bottom. –  Blowski Apr 18 '11 at 12:55
    
Hm, clearing the cache didn't help. Also it seems that a changed URL won't even get recognized, since it is still using the wrong file extension. –  Lars May 2 '11 at 9:12
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.