rails/turbolinks — pull request #286 by smidwap (2013-10-07 17:24:49+00:00)
Title: Transition cache

This is a continuation of https://github.com/rails/turbolinks/pull/248. I rebased master and took a completely different approach that I believe is more bug free.

I changed `pageCache` to use the url as a key. The `state` object now contains a `url` attribute instead of a `position`. This solves the issues brought up by @dhh.

However, this does introduce the problem of how to constrain the cache to a certain size...I haven't solved this problem yet but I am sure it can be solved.

A few other points

1. `reflectNewUrl` has been moved out of the xhr callback to make the code a bit cleaner. It was moved into the callback in https://github.com/rails/turbolinks/pull/231.
2. I removed the `xhr.abort` callback that calls `rememberCurrentUrl`. I did not see a regression from https://github.com/rails/turbolinks/pull/162. I believe this is due to using url's as keys.
3. I purposely ensured that `recallScrollPosition` was not called a second time if a cached copy is shown. @dhh's gist https://gist.github.com/dhh/8460cd271cc57dc361d0 called `recallScrollPosition` a second time, but that creates a scroll jump if the user starts scrolls after seeing a cached copy.
4. I don't have "opt out" built-in yet. That's trivial to build in once we decide what to do with this PR

I'd appreciate a second round of testing. Thanks!