       ).join("&")
 
   get: (resource, args, callback) ->
-    cache_entry = @_cache[resource]
-    if cache_entry
-      _console.debug "[Josh.FeedlyConsole] %s cached.", resource
-      return callback(cache_entry)
-
     unless chrome.extension?
       # not embedded, demo mode
       demo = demo_data[resource]
       demo = {} unless demo?
-      @_cache[resource] = demo
-      callback demo, null, null
+      callback demo, 'ok', null
     else
       url = [ @url, resource ].join('/') + @_url_parameters args
-      _console.debug "[Josh.FeedlyConsole] fetching %s at %s.", resource, url
+      _console.debug "[apirequest] fetching %s at %s.", resource, url
       request = @build_request url
-
-      $.ajax(request).done (response, status, xhr) =>
-        @_cache[resource] = response
+      $.ajax(request).always (response, status, xhr) ->
+        _console.debug "[apirequest] '%s' status '%s' response %O xhr %O.",
+          resource, status, response, xhr
         return callback response, status, xhr
 
   build_request: (url) ->


FEEDLY_API_VERSION = "v3"



class ApiRequest
  constructor: (@url) ->
    @_cache = {}

  url: ->
    @url

  @_NODES: {}
  @_NODES[@_ROOT_PATH] = null

  constructor: (@name, @path, @type, @json_data) ->
    @children = null
    FeedlyNode._NODES[@path] = @
    @type ?= 'node'

  @_initRootNode: =>
    @_ROOT_NODE ?= new RootFeedlyNode()

  @_getPathParts: (path) ->
    parts = path.split("/")
    #remove empty trailing element
    return parts.slice(0, parts.length - 1)  if parts[parts.length - 1] is ""
    return parts

  @_current: ->
    return Josh.config.pathhandler.current

  @_api:  ->
    return Josh.FeedlyConsole.api

  # normalize path
  @_resolvePath: (path) =>
    parts = @_getPathParts(path)

