Which and that mean different things in relative clauses. Here's a safe way to differentiate between them. (I'm telling you the U.S. grammar rule: easy to remember, easy to use.)

Use that when you want to say, 'I mean the one that...'
EXAMPLE: I missed the bus that was late.
THIS MEANS: I missed the bus, I mean the one that was late.

Use which when you mean, 'and by the way it...'
In other words, use which—plus compulsory commas—when you insert some non-essential information.

EXAMPLE: I missed the bus, which was late.
THIS MEANS: I missed the bus, and by the way it was late.

This guideline is often broken. In fact it is broken by many great writers and editors. Sometimes they are following the more complex British grammar rule. Sometimes they are guided by aesthetic considerations: they choose the word that sounds better.

If your meaning is clear, it often doesn't matter whether you use that or which. However, bear in mind that many people who use English as a second language are confused by incorrect grammar.

Now you know the simplest version of this grammar rule, you are free to make your own decisions. For more grammar tips, see our grammar course—or do it:
http://contented.com/courses/course/painless-grammar/

P.S. If you want to get picky, it's true that British writers have more wriggle room—but that just makes it harder to remember the rule. For example, New Hart's Rules (a British style guide) says:

in restrictive relative clauses either which or that may be used, but in non-restrictive clauses only which may be used.