Home > apple, web browsers > Nasty Bug: Safari doesn't cache stuff.

Nasty Bug: Safari doesn't cache stuff.

April 4, 2008
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.

  1. April 6, 2008 at 6:22 am

    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. April 6, 2008 at 9:25 am

    @Yusuf Goolamabbas

    Nope, makes no difference. 😦

  3. Richard
    April 7, 2008 at 5:10 am

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

  4. April 9, 2008 at 9:56 am

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


  5. April 9, 2008 at 3:38 pm

    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…

  6. Tom
    April 15, 2008 at 6:05 pm

    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/

  7. April 25, 2008 at 7:19 am

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

  8. Ben
    May 3, 2008 at 7:15 am

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

  9. Eric
    May 22, 2008 at 1:39 am

    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.

  10. May 28, 2008 at 5:25 pm

    Don, I think this is now fixed in 10.5.3.

  11. May 28, 2008 at 9:45 pm

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

  12. Kukurusta
    August 3, 2008 at 7:31 am

    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?

  13. aalessijr
    August 8, 2008 at 10:35 am

    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.

  14. August 8, 2008 at 10:42 am

    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?

  15. kukurusta
    August 12, 2008 at 10:16 am

    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.

  16. SY
    September 16, 2008 at 9:46 pm

    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.

  17. Fabiano
    September 26, 2008 at 9:36 am

    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.

  18. drokobegree
    December 19, 2008 at 10:13 pm

    Thak you for the news

  19. April 2, 2009 at 8:56 am

    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.



  20. October 26, 2009 at 3:48 pm

    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.

  21. November 6, 2009 at 4:00 pm

    Love it! You got me so excited to get one and start shooting video!

  22. enmity
    November 23, 2009 at 10:08 am

    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.

  23. enmity
    November 23, 2009 at 10:10 am

    Sorry, meant to post this site as the other example of a page where Safari caches properly:

  24. December 15, 2009 at 3:59 pm

    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.

  1. April 6, 2008 at 11:33 am
  2. April 6, 2008 at 2:22 pm
  3. May 6, 2008 at 3:39 am
  4. June 4, 2008 at 2:38 am
  5. September 26, 2008 at 4:37 pm
  6. September 27, 2008 at 12:56 am
Comments are closed.
%d bloggers like this: