   document.documentElement.appendChild body, originalBody
   document.documentElement.removeChild originalBody
   document.title = title
+  historyCache[window.history.state.position] = {url:document.location.href,body:body,title:title} if cache
+
 
 
 extractLink = (event) ->

  xhr.onabort = -> console.log("Aborted turbolink fetch!")
  xhr.send()

fetchHistory = (url) ->
  while(@historyCache.length > 0)
    cache = @historyCache.pop()
    if cache.url == url
      replaceDocument cache.body, cache.title
      triggerPageChange
      return

  fetchReplacement url

fullReplacement = (html, url) ->
  replaceHTML html
  triggerPageChange()

reflectNewUrl = (url) ->
  window.history.pushState { turbolinks: true }, "", url

triggerPageChange = ->
  event = document.createEvent 'Events'

historyCache = []

visit = (url) ->
  if browserSupportsPushState? and document.location.href != url
    reflectNewUrl url
    fetchReplacement url
  else
