Nasty Bug: Safari doesn’t cache stuff.

Strolling - Nairobi State Park by Simon Barnes

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.

Tags: , , , , , ,

23 Responses to “Nasty Bug: Safari doesn’t cache stuff.”

  1. Yusuf Goolamabbas Says:

    Don, You aren’t serving the files with any Cache-Control or Expires header ? Does it make any difference if you add those headers

  2. Don MacAskill Says:

    @Yusuf Goolamabbas

    Nope, makes no difference. :(

  3. Firebug for Firefox 3 :: Col’s Tech Stuff Says:

    [...] basis, especially now it’s much faster and integrates better on the Mac and given that Safari seems to be quite selective at what it caches. But not [...]

  4. Better, Stronger, Faster : Safari Caching Bug Says:

    [...] From: SmugBlog: Don MacAskill » Blog Archive » Nasty Bug: Safari doesn’t cache stuff. [...]

  5. Richard Says:

    I’ve always suspected this, but I didn’t think the Safari developers could make such an enormous oversight.

  6. Steve Leroux Says:

    There’s a bug in Webkit which seems to be related to this.

    http://bugs.webkit.org/show_bug.cgi?id=15798

  7. adamsky Says:

    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…

  8. Tom Says:

    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/

  9. Riccardo Says:

    I’d really like to know the solution for this actually.

  10. Ben Says:

    Safari 3.1.1 on Windows XP. How do I turn cache settings off?

  11. Performance web » Archive du blog » Limitations du cache WebKit Says:

    [...] où c’est plus étonnant c’est que Safari 3 a lui aussi des limitations qu’on n’attendait pas. Entre particulier les objets supérieur à 104 ko (le double si vous avez plus de 1 Go de RAM) ne [...]

  12. Eric Says:

    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.

  13. Yusuf Goolamabbas Says:

    Don, I think this is now fixed in 10.5.3.

  14. Mark Rowe Says:

    Yes, the fix for this issue is present in the Mac OS X 10.5.3 update released today.

  15. Safari Flash caching issue solved in 10.5.3 • cameronyule.com Says:

    [...] can confirm that the bug in Safari (and WebKit) which prevented caching of SWF files has been fixed by the recent 10.5.3 update to OS [...]

  16. Kukurusta Says:

    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?

  17. aalessijr Says:

    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.

  18. Don MacAskill Says:

    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?

  19. kukurusta Says:

    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.

  20. SY Says:

    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.

  21. Fabiano Says:

    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.

  22. Comment on Nasty Bug: Safari doesn’t cache bstuff/b. by Fabiano Says:

    [...] Fabiano wrote an interesting post today onComment on Nasty Bug: Safari doesnâ??t cache bstuff/b. by FabianoHere’s a quick excerptFor 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 b…/b [...]

  23. Comment on Nasty Bug: Safari doesn’t cache bstuff/b. by Comment on b…/b Says:

    [...] Comment on Nasty Bug: Safari doesnâ??t cache bstuff/b. by Fabiano wrote an interesting post today onComment on Nasty Bug: Safari doesnâ??t cache bstuff/b. by Comment on b…/bHere’s a quick excerptFabiano wrote an interesting post today onComment on Nasty Bug: Safari doesnâ??t cache bstuff/b. by FabianoHere’sa quick excerptFor these saying that dont care about it, try using safari over a Wireless Network, EDGE, or even 3G, b…/b [...]

Leave a Reply