Only update cachedPath to lastRedirect in a redirect

We should only update the cachedPath to the last redirect path if we are within a redirect. Otherwise this common case breaks.

1. Go to any page
2. Click a link which will cause a redirect
3. Click the browsers back button
4. Click the browsers forward button (Notice nothing happened)

@nickjs @hornairs for review