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.

There have been countless times where I run into a problem after I edit HTML on a Mac. The issue derives from me uploading the updated file to my server through FTP, and I'll navigate to the website in Safari. The one thing that didn't act properly was that Safari had already cached the webpage (the old version), so it would display the old version. I thought to myself and decided to clear the cache in Safari hoping it would solve my issue. Clearing the cache merely let the website appear to reload. It still came up with the old version of the file. To prove that the file on the server was actually updated, I got on another Mac on the same network, and it displayed the new version of the file. No matter how many times I refreshed or cleared the cache or reopened Safari, it would always deliver the old file. The only other solution I could come up with was to reboot. After a reboot, Safari reloaded the entire website and displayed the new version of the file.

I'm really just wondering how to flush Safari's cache and have it behave properly. Is this something the operating system does (I've had similar problems with files on my harddrive, too)? I don't want to have to reboot all the time just to see a new version of a file, so is there any way I can ensure I'm viewing the newest one? Is there a temporary storage folder that I can manually clear out? This happens to me quite often (not terribly frequent, but enough for me to notice), and my only current solution is to reboot.

I have strange feeling (it's not really a thought, but an ever so slight possiblilty that doesn't make much sense) that it's originating from a lower level.

share|improve this question
    
Use chrome (or opera)? –  Fake Name Mar 30 '12 at 6:44
    
I'd rather use Firefox, but I'm developing, so I need to test out my website on all browsers including Safari. –  Andrew Larsson Mar 30 '12 at 15:42

2 Answers 2

up vote 10 down vote accepted

In Safari, hold down down the (Shift) key while clicking the refresh button. This will perform a “hard” refresh, which bypasses the local cache.

(To quickly clear the cache in Safari, hit ++E, go to Privacy, and click “Remove All Website Data”.)

share|improve this answer
    
I'll definately try that next time I run into this issue. That's one thing that I haven't done yet. I've tried resetting Safari, clearing the cache, and even logging out and logging back in. Thanks for the great answer! –  Andrew Larsson Mar 30 '12 at 5:40
1  
Safari is a bit confusing in this aspect, as most other browsers use ++R to perform a hard refresh. In Safari, that doesn’t do anything, unless you focus the Web Developer Tools while performing the keyboard combo. –  Mathias Bynens Mar 30 '12 at 5:42
    
I'm going to accept your answer for now until somebody comes along with a better explanation with a proven solution to the ignorant caching I'm experiencing. Thanks! –  Andrew Larsson Mar 30 '12 at 5:45
1  
@AndrewLarsson Anyway, after a hard refresh you should always get the latest version, assuming there’s no weird server-side caching going on. Which reminds me, what caching headers does the server send along with the file? It could be a server configuration issue. –  Mathias Bynens Mar 30 '12 at 5:46
    
That was another thing I was thinking. If the server is returning a 304 when, in fact, it should be returning new content, it'd be something I need to change in my configuration. I'll investigate this the next time I come across this problem. –  Andrew Larsson Mar 30 '12 at 5:50

I had the exact same problem except I noticed that it was happening with other browsers too. As it turns out it was not Safari or OSX it was a cache created by the service provider.

To solve the problem I put code in my page to prevent it from being cached.

content="no-cache"

"Some people know about the browser caching, but still get taken aback by ISP caching. ISP caching works in much the same way as browser caching. Once you have visited a website your ISP may cache those pages so that they appear to load faster the next time you visit them. The main problem with this is that unlike your browser cache you can not delete these temporary files, instead you have to wait until your ISPs cache expires and it requests fresh copies of the files. This can be very frustrating if you are trying to develop or make changes to your website -- or even to look at new information."

share|improve this answer
    
Can you please put back to full code (as you had in the first version of the answer)? If you put four spaces at the beginning of the line, there shouldn't be any problems with formatting. –  patrix May 27 '13 at 11:37
    
This is a good point, and I'll try it next time. However, I'm not sure how well it would apply to the situation I described in the question, because the Macs I used were both on the same network and had the same global IP (so the ISP wouldn't be able to determine the difference between the them). –  Andrew Larsson May 28 '13 at 20:29

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.