Cache dependencies on CI.

Make the CI runs more efficient by caching dependencies and only installing newer, compatible versions.