How to cache salesforce api responses at edge
Reduce Salesforce API daily limit usage
Cache read-heavy Contact and Account queries with short TTL. For "how to cache salesforce api responses at edge", store SALESFORCE_ACCESS_TOKEN in Secret Vault, call https://{{secrets.SALESFORCE_INSTANCE}}.my.salesforce.com/services/data/v68.0/sobjects/Contact/{{query.contactId}} from a Worker, and let Frontend / Web hit only https://realcomposer.com/v1/workspace/cache-salesforce-api-at-edge with an rc_live_ client token. Enable 300s GET cache only when query params identify the resource.
Salesforce rate limits from Frontend / Web traffic
Without edge caching, identical Salesforce reads during a session still round-trip to the origin.
- HTTP 429 responses during launch traffic
- Surprise SaaS overages from duplicate reads
- Slower repeat views than necessary
How RealComposer Solves This at the Edge
Add vault secrets for this pipeline
Create SALESFORCE_ACCESS_TOKEN vault entries, then bind them to this pipeline step headers with {{secrets.NAME}} placeholders.
Set headers, mapping, and cache TTL
Configure headersTemplate to inject vault secrets, target https://{{secrets.SALESFORCE_INSTANCE}}.my.salesforce.com/services/data/v68.0/sobjects/Contact/{{query.contactId}}, and Add output mapping fields that mirror the JSON contract your screen already expects.
Call from Frontend / Web
Call https://realcomposer.com/v1/workspace/cache-salesforce-api-at-edge with a restricted rc_live_ client token. Frontend / Web never sends upstream secrets.
const res = await fetch('https://realcomposer.com/v1/workspace/cache-salesforce-api-at-edge', {
headers: { Authorization: 'Bearer rc_live_your_token' }
});
{
"requestId": "req_cache-sa",
"upstreamLatencyMs": 142,
"audit": {
"region": "edge",
"trace": "cache-salesforce-api-at-edge"
},
"payload": {
"id": "sample_id",
"status": "active",
"nested": {
"tags": [
"demo"
],
"internal": true
},
"unused_blob": {
"foo": "bar",
"bar": "baz"
}
}
}
{
"contactId": "sample",
"email": "sample",
"name": "sample"
}
Recipe Specs
- HTTP method
- GET
- Upstream calls
- 1
- Edge cache TTL
- 300s
- Client auth
- Restricted client token
- Mapped output fields
- 3
- Payload
- 247 B to 55 B (-78%)
curl -X GET "https://realcomposer.com/v1/workspace/cache-salesforce-api-at-edge" \ -H "Authorization: Bearer rc_live_client_token"
Developer Questions & Troubleshooting
Can Frontend / Web call Salesforce without holding the production key?
Point Frontend / Web at /recipes/cache-salesforce-api-at-edge edge URL. RealComposer answers OPTIONS with Access-Control headers for allowed origins.
Does POST traffic get cached?
cache-salesforce-api-at-edge POST steps bypass caches.default even if cacheTtlSeconds is set in the dashboard.
How do I rotate upstream credentials?
Rotate vault secrets for cache-salesforce-api-at-edge anytime; clients keep the same rc_live_ token.
Sources & Definitions Used in This Answer
Deploy this Frontend / Web + Salesforce Recipe
Clone this pre-configured pipeline into your RealComposer workspace in one click. We pre-populate upstream URLs, headers, and mapping rules.