I have some code that needs to be a local backup of key data from my Salesforce Instance's Schema. I want to alert my user any time the Salesforce (remote) schema slips out of sync with my local copy and prompt them to refresh the local copy.

I'm now pretty comfortable with the REST api via the excellent Rails restforce gem, but i'm struggling to come up with a speedy and elegant way to check for changes to my instance.

Initially I'd tried making a .describe call (nb below client is an object that contains and formats auth data)

Digest::MD5.hexdigest(client.describe) => cfa443badd87ee0578e812a007b1f303 

ie, I get a call back from global describe, turn it into a string and make a checksum via MD5.

However, I've noticed since adding new fields to the instance the checksum doesn't change, seems that global describe doesn't hold any data on fields. So I tried a dynamic:

client.describe.map {|o| client.describe( o['name'] ) }

ie, do a global call, grab iterate through the objects and call an additional describe and grab all field data. I can then turn this back into a string and run it through my MD5 checksum... But this takes... AGES. Our instance has 300+ objects, this code takes +1 min to run.

Does anyone have a smarter, more efficient and quicker way to poll for changes to the schema via the REST API?

With my current implementation I'm able to tack it on at the start of already long running activities that depend on the schema's being in sync. It can then throw an error and suggest remediation if they're not... but ideally I'd have a nippy little bit of code I could use more widely to prompt the user via notices/flashes to take action from many different points within the app.

Anyone ever tried anything similar? Any ideas would be great!

2 Answers 2


Use the If-Modified-Since header to check for changes. Basically, when performing a describe by REST, this header lets developers know if there's been any changes since the last describe.

Use the SObject Describe resource and the If-Modified-Since HTTP header to determine if object metadata has changed.

You can include the If-Modified-Sinceheader with a date in EEE, dd MMM yyyy HH:mm:ss z format when you use the SObject Describe resource. If you do, response metadata will only be returned if the object metadata has changed since the provided date. If the metadata has not been modified since the provided date, a 304 Not Modified status code is returned, with no response body.

  • ! Legend, will have a sleuth through the restforce response headers now. Any idea if this works with global describe?
    – Huw
    Commented Aug 17, 2016 at 14:21
  • @Huw no, you can only use headers like this on object describes and records, as far as I can tell. This means you'll have to do a full describe periodically to check for new/changed/deleted objects.
    – sfdcfox
    Commented Aug 17, 2016 at 14:29
  • I dunno actually... I think i have got something on global describe... If i go to workbench => rest explorer and go /services/data/v37.0/sobjects I can see this in the raw response headers: Last-Modified: Tue, 16 Aug 2016 15:52:37 GMT... which i reckon is when i last added a field... now to work out how to get this back out of restforce!
    – Huw
    Commented Aug 17, 2016 at 14:30

Thanks to @sfdcfox for his comment above - turns out the Last Modified header appears to be there for global describe.

so a simple restforce call:


Gives me a datetime formatted as a string, but i can use response.to_datetime to do a comparision against something stored in local database - awesome!

  • I came along same sort of situation. Where I want to have a checksum kind of thing so that we don't always make sync. Instead check with a quick step to identify if there's any change or not. Would you please spare some time to discuss the approach you adopt. And for any guidance and suggestions please?
    – Superman
    Commented May 17, 2022 at 12:25

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .