PuppyIP Resource Center
Cloud Operations 5 min Published 2026-11-19

CloudFront Functions network calls: cf.fetch, cf.beacon, and the 1-second limit

CloudFront Functions can now call an origin configured on the same CloudFront distribution. Use cf.fetch when the current viewer request needs the result and cf.beacon for background telemetry that can tolerate loss. Both share a quota of one network call per invocation, with a 1-second timeout. Check the origin, plan, and test path before using the call on production requests.

AWS CloudFront CloudFront Functions cf.fetch cf.beacon Network calls

Service eligibility and regional restrictions

PuppyIP serves only compliant overseas businesses and their authorized personnel. Proxy services are not available in mainland China. The service may only be used for lawful business activities outside mainland China. Use of this service within mainland China is prohibited.

Hosting a proxy IP or server overseas does not change these restrictions. The service must not be provided to end users in mainland China through relaying, forwarding, sharing or resale. Before use, read the Terms of Service.

Key Takeaways

  • Use JavaScript runtime 2.0 with a viewer request or viewer response function.
  • Call from inside the handler with a slash-prefixed path and a configured originId.
  • The methods share one call per invocation. Request and response bodies each have a 10 KB limit.
  • The console Test tab and TestFunction cannot make real network calls.

Check the origin and function runtime first

AWS announced network call support on November 18. The developer guide uses JavaScript runtime 2.0 and imports cf from cloudfront. Call from inside a viewer request or viewer response handler. Supply a path and the originId for an existing origin on the same distribution. A full URL with an external hostname is not a valid path.

Using a configured origin carries over applicable CloudFront features such as origin access control and VPC origins. Function network calls have their own 1-second timeout. A longer response timeout in the origin settings does not extend it. Connection Functions and distributions that use continuous deployment do not support these network calls.

When to choose cf.fetch or cf.beacon

Use cf.fetch if the current response needs data from the origin, such as a small status response that determines how to handle the viewer request. Check the returned status and define what happens on timeouts, origin failures, or unexpected responses. The invocation has only one network call, so a second call is not available as an in-function fallback.

Use cf.beacon for telemetry that can tolerate loss. The call returns immediately and later delivery failures are not sent back to the function. If you need visibility, enable logDeliveryErrors and check CloudWatch Logs as described in the guide. Work that must be delivered belongs in a durable queue or a separately retryable process.

Budget for the round trip and body limits

AWS measures the 1-second limit from sending the request to receiving the last byte. Each invocation can make one network call in total. Request and response bodies are limited to 10 KB each, and response streaming is unavailable. CloudFront does not cache network call responses. Estimate origin load from the traffic that will actually execute the branch with the call.

For example, sample optional request telemetry if you only need occasional events from a static response. If every request depends on a value that rarely changes, evaluate whether CloudFront KeyValueStore fits before adding an origin round trip to each request.

Separate local logic tests, live calls, and charges

A TypeError that says network calls are unavailable in the console Test tab or the TestFunction API is a documented limitation. Test the function branches for valid responses, timeouts, and unexpected input, then verify actual calls using a separate test distribution you control. Observe the viewer outcome, origin status, and latency before routing production traffic through the call.

AWS announced a pay-as-you-go price of $0.10 per million network calls on top of CloudFront Functions invocation charges. CloudFront flat-rate plans include the feature at Pro and above without an additional charge for calls. The flat-rate Free plan does not support it. Check your distribution's plan, current pricing, and usage records.

Sources

Frequently Asked Questions

Can one invocation fetch and then send a beacon?

No. They share one network call per invocation. Select the appropriate call for the current branch and handle the other work separately.

Will increasing the origin timeout to 5 seconds help?

A function network call still has a 1-second limit from sending the request to receiving the last byte.

Does a passing console test prove the origin call works?

The console does not execute the network call. Check actual requests, origin results, and failure behavior on a controlled test distribution.