 
     params = {}
     if metadata.providerData.id then params.recordid = metadata.providerData.id
-    if metadata.name then params.recordname = metadata.name
-
-    url = @_addParams(saveDocumentUrl, params)
+
+    # See if we can patch
+    if metadata.overwritable and @previouslySavedContent and
+        diff = @_createDiff @previouslySavedContent, content
+      sendContent = diff
+      url = patchDocumentUrl
+    else
+      if metadata.name then params.recordname = metadata.name
+      url = saveDocumentUrl
+      sendContent = content
+
+    url = @_addParams(url, params)
 
     $.ajax
       dataType: 'json'
       method: 'POST'
       url: url
-      data: content
-      context: @
-      xhrFields:
-        withCredentials: true
-      success: (data) ->
+      data: sendContent
+      context: @
+      xhrFields:
+        withCredentials: true
+      success: (data) ->
+        @previouslySavedContent = content
         if data.id then metadata.providerData.id = data.id
         callback null, data
       error: ->

      xhrFields:
        withCredentials: true
      success: (data) ->
        callback null, JSON.stringify data
      error: ->
        callback "Unable to load "+metadata.name


    return JSON.stringify content

  _createDiff: (json1, json2) ->
    try
      diff = jiff.diff(JSON.parse(json1), JSON.parse(json2))
      return JSON.stringify diff
    catch
      return null

module.exports = DocumentStoreProvider
