> ## Documentation Index
> Fetch the complete documentation index at: https://docs.browserbase.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Cost optimization

> Your guide to lowering your browser infrastructure costs

This guide outlines best practices to minimize infrastructure costs while maintaining performance.

## Session management

### Reusing sessions

To optimize costs, consider reusing browser sessions since there's a one-minute minimum billing period for each session creation. For short tasks, reusing sessions helps avoid multiple minimum charges. For longer workflows, you can disconnect and reconnect to the same session as needed, maintaining efficiency while managing resource usage.

To reuse a session:

* Store the session ID from your initial session creation

* Use the `sessionId` query parameter when connecting to specify the existing session

* Continue using the same session for similar workloads

Learn more about [connecting to sessions here](/platform/browser/getting-started/using-browser-session).

### Serverless execution model

For short-lived, event-driven automations, [Functions](/platform/runtime/overview) provide a cost-effective alternative to manually managing sessions:

* **No minimum runtime waste**: Functions only bill for actual execution time
* **Zero infrastructure overhead**: No session management or keep-alive costs
* **Automatic cleanup**: Sessions are automatically terminated after function completion
* **Perfect for**: Webhooks, scheduled tasks, API endpoints, and one-off automation

Functions are ideal when you don't need persistent sessions or manual control over the session lifecycle.

## Proxy optimization

Proxy usage can impact costs. Implement these strategies to minimize proxy-related expenses:

### Selective proxy usage

Proxies are a powerful tool if you need to access geo-restricted content, have load balancing requirements, or need anonymity, but if those aren't necessary, avoiding proxies saves on costs.&#x20;

You can also implement domain-specific proxy routing. For more information, see [Proxy Configuration](/platform/identity/proxies#proxies-routing-rules).

### Image loading optimization

When using proxies, control image loading to reduce bandwidth costs.&#x20;

Ensure images are disabled for non-visual automation:

<Tabs>
  <Tab title="Node.js">
    <CodeGroup>
      ```typescript Playwright theme={null}
      await page.route('**/*', (route, request) => {
        if (request.resourceType() === 'image') return route.abort();
        return route.continue();
      });

      await page.goto('https://example.com');
      ```

      ```typescript Puppeteer theme={null}
      await page.setRequestInterception(true);
      page.on('request', (request) => {
        if (request.resourceType() === 'image') request.abort();
        else request.continue();
      });

      await page.goto('https://example.com');
      ```
    </CodeGroup>
  </Tab>

  <Tab title="Python">
    <CodeGroup>
      ```python Playwright theme={null}
      def block_images(route, request):
          if request.resource_type == "image":
              route.abort()
          else:
              route.continue_()

      page.route("**/*", block_images)
      page.goto("https://example.com")
      ```
    </CodeGroup>
  </Tab>
</Tabs>

<Note>
  Blocking images or other resources via request interception (`page.route`) is not recommended on sites with bot protection. Many bot protection systems rely on image and font loading to verify browser behavior, and intercepting requests can negatively impact session performance. Reserve this optimization for sites where bot protection is not present.
</Note>

If you're scaling up and looking for bulk usage discounts, reach out to [hello@browserbase.com](mailto:hello@browserbase.com).
