         @$container.find(@options.navSelector).each(@options.loading)
 
     _success: ->
+      # ignore any requests that started before we last invalidated
+      return if @_isInvalidatedRequest(@requestAts.shift())
+      @_recache()
       @options.state.loading = false
       @_log "New page loaded!"
       if typeof @options.success is 'function'
         @$container.find(@options.navSelector).each(@options.success)
 
     _error: ->
+      # ignore any requests that started before we last invalidated
+      return if @_isInvalidatedRequest(@requestAts.shift())
       @options.state.loading = false
       @_log "Error loading new page :("
       if typeof @options.error is 'function'

(($, window) ->
  # Define the plugin class
  class InfinitePages

    # Default settings
    defaults:

      @_log "Scroll checks resumed"
      @check()

    _recache: ->
      # Recache the element references we use (needed when using turbolinks)
      @$container = $("[data-jquery-infinite-pages-container=#{@instanceId}]")
      @$table = @$container.find('table')
      @$context = $(@options.context)

    _invalidateActiveRequests: ->
      # Invalidate any active requests (needed when using turbolinks)
      @invalidateAt = +new Date

    _isInvalidatedRequest: (requestAt) ->
      # Check to see if a request was invalidated
      requestAt < @invalidateAt

  # Define the plugin
  $.fn.extend infinitePages: (option, args...) ->
    @each ->
