Pages

6 August 2009

Safari on Mac caching is broken for web hosts having CNAMEs

It took a day to figure it out. We have an internal website which loads perfectly in all browsers, except for the people using Safari, where Safari insisted on re-loading all the static dependencies of a page, and took 30 seconds to do so. Instead of taking .1 seconds (Firefox on Linux, caching all dependencies), or 4 seconds (hard page refresh in Firefox), Safari would take 18-30 seconds to load a page - making the site unusable. Later, we found that it was just Safari on Mac: Safari on Windows behaves just like Firefox and IE with respect to caching. The plot thickened further when I telnetted to port 80 on the server to check for proxies in the way: according to telnet the server had a different name. I did a host lookup and found that the server was a CNAME pointing to another name, which had the actual record. For example, blog.grahampoulter.com is a CNAME pointing to ghs.google.com which actually hosts this blog. On a hunch, I requested an A record to make the server name resolve directly to the IP address instead of looking up another record first. Lo and behold, Safari 4 on Mac started caching the pages properly. So, I broke Safari - on Mac Safari #fails to cache pages loaded from a server whose DNS is a CNAME pointer instead of an A record. A lot of web servers have CNAMEs pointing at them, and if every time a Safari-on-Mac browser visits one it reloads all the page dependencies, that's a lot of loading. Now, would someone who actually uses a Mac please confirm and file a bug report for me?