Nasty Bug: Safari doesn't cache stuff.

photo by: Simon Barnes
I swear I’m not making this up.
I couldn’t believe my eyes when I found it. Safari is one of our favorite browsers, and we love their work on standards compliance and speed, particularly JavaScript, but this particular bug is really driving us crazy. I’ve logged it with Apple (#5786274), and a fix is promised, but in case you’re getting hit with this and are as baffled as I was, here are the details:
- If your computer has less than 1GB of RAM, Safari fails to cache items larger than 104,857 bytes.
- If your computer has more than 1GB of RAM, Safari failes to cache items larger than 209,715 bytes.
- JPEGs, at least, are temporarily cached in RAM. Whew. But upon browser restart, you’ll see they didn’t make it to the disk cache, so you have to get them again.
- Other objects, like SWFs or videos, though, don’t even make it to the RAM cache, let alone disk. Load the same SWF back-to-back, and you’ve just transfered the bytes twice. Ugh.
Very easy to reproduce yourself from the comfort of your own home, so go for it. Just fire up HTTP Scoop or Wireshark or tail your server’s HTTP logs and start hitting stuff. Marvel at the # of excess bytes transferred across the wire that you didn’t need. 😦
Here are a couple of test URLs so you can see for yourself:
As a self-professed Apple fanboy, I can’t wait for a fix. In the meantime, we’ve had to jump through all sorts of hoops to ‘dumb down’ some of our most exciting new features. 😦
UPDATE: Yes, I’ve tried with every Cache-Control and Expires header known to man. No, it doesn’t make a difference. Try it yourself.
Don, You aren’t serving the files with any Cache-Control or Expires header ? Does it make any difference if you add those headers
@Yusuf Goolamabbas
Nope, makes no difference. 😦
I’ve always suspected this, but I didn’t think the Safari developers could make such an enormous oversight.
There’s a bug in Webkit which seems to be related to this.
http://bugs.webkit.org/show_bug.cgi?id=15798
And to be honest – why should I care for this? In fact I always turn all the cache settings off. I really prefer my browser to get all the content “on-the-fly” from the web, even if it’s a little slower…
Ahh, nice catch. I just noticed this today on our app too.
p.s. Charles is a nice HTTP monitoring app too: http://www.xk72.com/charles/
I’d really like to know the solution for this actually.
Safari 3.1.1 on Windows XP. How do I turn cache settings off?
I just found this out the hard way – made a large flash site that preloads content in the background and relies on it being cached (files are 5mb+) – doesn’t work at all on latest safari basicly, this is a disaster 😦 Any hints about fixes for this would be greatly appreciated.
Don, I think this is now fixed in 10.5.3.
Yes, the fix for this issue is present in the Mac OS X 10.5.3 update released today.
It seems that Safari 3.1.2 (5525.20.1) on 10.5.4 doesn’t cache *any* files again independently from the size. I’m so stumped, that I cross-checked all preferences a dozen of times. Can anyone confirm?
Confirming that Safari 3.1.2 (5525.20.1) on 10.5.4 with all Apple security updates does not cache any files on my configuration: G4 FW800 Dual 1.25G, 768MB RAM.
I’m unable to reproduce the problem with Safari 3.1.2 (5525.20.1). All files, even large SWF and JPEGs, seem to be caching fine for me.
Can you provide some examples and your test methodology so I can verify?
I used ngrep/tcpdump to really check what goes through the wire. I also checked access logs on some web server I’ve access. It really seems, that Safari doesn’t even respect Cache-Control/Expires HTTP headers. It didn’t see not one “HTTP/1.1 304 Not Modified” while sniffing. Firefox does for the same sites.
Safari 3.1.2, osx 10.5.4, 2.16 GHz Intel Core Duo(2 GB 667 Mhz DDR2 SDRAM)17″MackBook Pro – Not Caching
Safari 3.1.2, osx 10.4.11, Dual 2.7 GHZ PowerPC G5(8 GB DDR SDRAM) – Not Caching.
I have noticed this a few years ago, and looks to be the same as I test today. Yeah, I usually use Firefox.
I don’t understand why this has not been fixed.
For these saying that dont care about it, try using safari over a Wireless Network, EDGE, or even 3G, and you´ll se how frustating it is to not having cache. Specially when you are using a limited data plan. Actually I use the Internet with my Macbook Pro in most of the time over 3G wireless network, and its not so fast as a DSL or Cable connection. I love Safari but I was force to swith to Firefox because of this.
Thak you for the news
I recently came across your blog and have been reading along. I thought I would leave my first comment. I don't know what to say except that I have enjoyed reading. Nice blog. I will keep visiting this blog very often.
Joannah
http://transcendmemory.net
I'm using a older version of Safari and don't want upgrade, Hope they solved this in the new version. I might give a it a try.
Love it! You got me so excited to get one and start shooting video!
No cache bug when testing here or at http://blogs.smugmug.com/don/2008/04/04/nasty-bug…
using Safari 4.0.4 on Windows XP. Cache works properly, as long as Private Browsing is turned off (as expected). Cache even persists after closing and restarting Safari.
Sorry, meant to post this site as the other example of a page where Safari caches properly:
http://www.rudinswagerman.nl/weblog/index.php?id=…
I've just come across on your blog and read about that Safari browser. I installed a version 4.0.3 for Windows. First impression, especially Top sites with 24 top visited sites I like it.
After I tested I can talk about any bugs.