Simon: "Hello, is John there please?"No problems here. But eventually, John decides to move in with his girlfriend, but forgets to tell Simon the exact date.
Me: "No, he's at his girlfriend's this afternoon. Her number is ..."
Simon: "Ok, thanks."
Simon: "Hello, is John there please?"So, now I no longer have a flatmate called John. Then, one day:
Me: "No, he's moved in with his girlfriend. His new number is ..."
Simon: "Ok, thanks."
Simon: "Hello, is John there please?"Then another day:
Me: "No, he moved out, remember? His new number is ..."
Simon: "Ok, thanks."
Simon: "Hello, is John there please?"This is obviously wrong. When John was out for the afternoon, it was okay for Simon to ring and ask for John. But when I told Simon that John no longer lives here, Simon should just remember John's new number and start ringing that instead.
Me: "No, I told you before, his new number is ..."
Simon: "Ok, thanks."
This, ladies and gentleman, is the difference between a temporary redirection and a permanent redirection. Those of us in the know call them a 302 and a 301. They behave exactly like I've described above -- if the server sends a 302, the client should keep checking back with the server for the resource in case its URL changes.
If it sends back a 301 though, it's permanent. Never going to change. Never. So, the client may as well remember that, and indeed, this is what the spec says:
This response is cacheable unless indicated otherwise.(Note that the spec never really says "Cache it, or else" -- it only gets worked up over things that aren't cacheable.)
So, any decent browser worth its salt will be caching this response, right? Wrong. Although there have been posts asking about this, it turns out that the neither Firefox nor Internet Explorer cache any kind of 3xx redirection. The only one I've come across that does is Google Chrome (as also noted by Mauricio Scheffer).
This is really annoying, and I spent a morning tearing out my hair trying to understand why this wasn't working. Hopefully this post means somebody else loses a bit less time.
So, in summary:
Google Chrome: good
Firefox: bad
Internet Explorer: bad
If you want to test your browser, I recommend the excellent suite of tests written by Mark Nottingham. He has also written an excellent introductory guide to caches, which I suggest you read to understand this area.
2 comments:
Who's John?
A hypothetical flatmate.
Post a Comment