 installHistoryChangeHandler = (event) ->
   if event.state?.turbolinks
     if cachedPage = pageCache[event.state.url]
+      cacheCurrentPage()
       fetchHistory cachedPage
     else
       visit event.target.location.href

xhr            = null


fetchReplacement = (url) ->
  rememberReferer()
  cacheCurrentPage()
  reflectNewUrl url

  triggerEvent 'page:fetch', url: url

  xhr?.abort()

  xhr.send()

fetchHistory = (cachedPage) ->
  xhr?.abort()
  changePage cachedPage.title, cachedPage.body
  recallScrollPosition cachedPage
