---
title: How to run ISR on Vercel behind an external CDN or proxy
description: Keep Vercel as the only HTML cache when another CDN or proxy sits in front of your project. Bypass ISR routes at the proxy one route at a time, purge safely, and verify from response headers.
url: "https://vercel.com/kb/fde/run-isr-behind-external-cdn-or-proxy"
published: 2026-12-03
last_updated: 2026-12-03
authors: Mark Faraj
---

# How to run ISR on Vercel behind an external CDN or proxy

Keep Vercel as the only HTML cache when another CDN or proxy sits in front of your project. Bypass ISR routes at the proxy one route at a time, purge safely, and verify from response headers.

An external CDN can keep serving an old page after Vercel regenerates it. Bypass the external cache for routes that use [Incremental Static Regeneration (ISR)](https://vercel.com/docs/incremental-static-regeneration) so Vercel controls their caching and revalidation.

The Pages Router examples support a route-by-route rollout while you retain the proxy for required routing or security controls. If you can remove it, [send traffic directly to Vercel](https://vercel.com/docs/security/reverse-proxy) to avoid the extra caching and firewall limitations.

## Before you start

Use a deployed Next.js Pages Router project with routes configured for ISR. You'll need access to the external proxy's cache rules and purge controls, plus a test hostname that follows the same request path as your users.

For response-header bypasses, confirm your provider's supported header and any configuration needed to honor it. Keep application-specific conversion and personalization work separate from this cache change.

## How it works

For each converted route, let Vercel cache the ISR response and configure the external proxy to pass requests through. Routes that still use `getServerSideProps` need their own cache policy. [Public SSR responses can be cached](https://nextjs.org/docs/pages/building-your-application/data-fetching/get-server-side-props#caching-with-server-side-rendering-ssr) with explicit cache headers, while personalized responses must stay out of a shared cache.

The bypass can live in the proxy's path-based rules or in a provider-specific response header. Proxy rules can skip the cache lookup before serving a stored response. Response headers take effect only when the proxy fetches from Vercel, which changes how you coordinate deployment and purging.

> **Warning:**
>
> Avoid `CDN-Cache-Control: no-store` by itself for the external bypass because Vercel also reads it. Vercel gives `Vercel-CDN-Cache-Control` priority over `CDN-Cache-Control`, then falls back to `Cache-Control`. Follow this [header precedence](https://vercel.com/docs/caching/cache-control-headers#behavior) and let Next.js manage the ISR cache policy.

## Configure the proxy for ISR

### 1\. Confirm the request path

Check how the hostname resolves and how the proxy is configured. External authoritative DNS can still direct traffic through a proxy, including a CNAME-based setup. Inspect CNAME, A, and AAAA answers for the same hostname, then confirm the path with the provider's response headers or request logs:

```bash
dig +short www.example.com CNAME
dig +short www.example.com A
dig +short www.example.com AAAA
```

Compare the resolved addresses with your proxy configuration and the current values in Vercel's **Domains** settings. Repeat for each hostname because staging, preview, and production can follow different paths. CNAME flattening can leave the CNAME answer empty even when traffic uses the proxy; check both IPv4 and IPv6 if they resolve differently.

### 2\. Plan the route rollout

List the converted routes and start with those carrying the least traffic and risk. Group related routes in one release only when they share the same caching policy. For example, `/blog` and its article and pagination routes can share a prefix rule after you confirm that it excludes personalized responses and unconverted routes.

Inventory the requests behind each route as well as its public URL. Pages Router navigation fetches [page data as JSON](https://nextjs.org/docs/pages/building-your-application/data-fetching/get-static-props#statically-generates-both-html-and-json) under `/_next/data/`, so an external rule for `/blog` alone doesn't cover that data. Include the corresponding data requests, locale prefixes, and base paths in your bypass, purge, and verification checks. Keep hashed assets under `/_next/static/` on their existing cache policy.

### 3\. Configure the external cache bypass

Choose the bypass mechanism your proxy supports and coordinate it with each route's ISR deployment. The configuration needs to cover the page and data requests identified in your rollout plan.

#### Add a path-based rule

Configure the proxy to skip caching for the converted routes and their data requests. Check rule order and any exceptions that could override the bypass. Where the origin can handle the temporary uncached traffic, activate and verify this rule before promoting the ISR deployment.

#### Use a provider-specific response header

Use this option only if your CDN documents a header that prevents caching and your configured rules honor it. Cloudflare supports [a dedicated cache-control header](https://developers.cloudflare.com/cache/concepts/cdn-cache-control/), but its cache rules can override origin headers. If your provider has no suitable header, use a path-based rule instead.

Merge a [`headers()`](https://nextjs.org/docs/pages/api-reference/config/next-config-js/headers) [rule](https://nextjs.org/docs/pages/api-reference/config/next-config-js/headers) into your existing Next.js config, preserving other options, rules, and the file's module format. Replace `Your-CDN-Cache-Control` with your provider's documented header name. The CommonJS configuration uses `/blog/:path*`, which matches `/blog` and every descendant:

```javascript
/** @type {import('next').NextConfig} */
module.exports = {
  async headers() {
    return [
      {
        source: '/blog/:path*',
        headers: [
          // Replace with your provider's documented header.
          {
            key: 'Your-CDN-Cache-Control',
            value: 'no-store',
          },
        ],
      },
      // Keep existing header rules here.
    ];
  },
};
```

Use narrower source patterns if server-rendered routes remain under that prefix. Next.js applies configured locale and `basePath` prefixes to header sources by default, so test the URLs visitors request and their page-data responses. Deploy the header with the converted route, then confirm it on the intended Vercel deployment before purging the proxy. Existing proxy entries can keep serving the old response until that purge completes.

### 4\. Purge previous responses

After confirming the deployment and bypass policy are active, purge the converted routes using your provider's URL, prefix, or tag purge controls. Include every affected hostname and cached representation, including page data. Cover both trailing-slash variants and any other variants used in your proxy's cache key.

An effective request-time bypass already skips old entries; purging removes them so they can't reappear if caching is later enabled. For a response-header bypass, purging forces the proxy to fetch the new policy.

Before rolling back, ensure the bypass will survive the rollback. If it comes from application response headers, retain those headers in the rollback release or activate a temporary proxy-side bypass first. Restore and check the previous deployment, then purge affected entries before restoring an earlier proxy cache policy. Restore caching only for responses that are safe to share.

### 5\. Verify caching and revalidation

Request a converted page with GET and keep the HTTP status visible. This command discards the response body and prints the headers:

```bash
curl --fail --silent --show-error \
  --dump-header - --output /dev/null \
  https://www.example.com/blog/launch-week
```

Run the command again for the same URL. Check for a successful HTML response, then inspect the proxy's documented cache status and Vercel's status. If it redirects, test the final page URL separately. Missing diagnostic headers and HTTP errors need investigation before you accept the rollout.

| Header                                                           | What to check                                                                                                                                        |
| ---------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------- |
| Proxy cache status                                               | Its documented bypass or uncacheable status. Interpret the value using your provider's definitions.                                                  |
| [`x-vercel-cache`](https://vercel.com/docs/caching/cache-status) | `HIT` or `PRERENDER` can indicate cached or prerendered output. `MISS`, `STALE`, or `REVALIDATED` can occur while content is generated or refreshed. |

Confirm the proxy bypass before relying on Vercel's status, since an external cache can replay a stored header. After an authorized content change and revalidation, verify the updated content through the public hostname on both a full page load and client navigation. Allow a bounded retry window for regeneration instead of requiring `HIT` on a fixed request number.

### 6\. Check bypass rules in CI

For the response-header option, check the headers returned by a local production build. Build and start the app with its production scripts, then run the test while the server is running. Use Node.js 20 or later with its built-in test runner.

Save the test in the file shown below. Replace the header placeholder with the name used in your config, and add your converted page URLs to `ISR_PATHS`, including locale and base-path prefixes:

```javascript
import assert from 'node:assert/strict';
import test from 'node:test';

const baseUrl = process.env.ISR_TEST_BASE_URL;
assert.ok(
  baseUrl,
  'Set ISR_TEST_BASE_URL to the production server',
);

// Use the same documented header name as next.config.js.
const BYPASS_HEADER = 'Your-CDN-Cache-Control';
const ISR_PATHS = ['/blog/launch-week'];

for (const path of ISR_PATHS) {
  test(`${path} sends the proxy bypass header`, async () => {
    const response = await fetch(new URL(path, baseUrl), {
      redirect: 'manual',
      signal: AbortSignal.timeout(10_000),
    });
    await response.body?.cancel();
    assert.equal(response.status, 200, `${path}: expected a page`);
    assert.match(
      response.headers.get('content-type') ?? '',
      /text\/html/i,
    );
    assert.equal(response.headers.get(BYPASS_HEADER), 'no-store');
  });
}
```

Run the test from the project root with the address of your local production server:

```bash
ISR_TEST_BASE_URL=http://localhost:3000 \
  node --test tests/headers.smoke.test.mjs
```

In CI, wait for the production server to become ready before running the test, then stop it when the job finishes. Keep the URL list in sync with each route conversion or generate cases from an existing route inventory. Unlisted routes aren't checked.

This test checks HTML response headers at the origin. After deployment, verify the proxy's effective policy for both page and data requests using the [caching and revalidation checks](#5.-verify-caching-and-revalidation). Use those deployment checks for proxy-side rules too.

## Account for App Router requests

The external-cache bypass goal also applies to the App Router, but its rendering model affects what you test. Without Cache Components, reading `cookies()` or `headers()` in a page or layout opts the route into dynamic rendering. With [Cache Components](https://nextjs.org/docs/app/api-reference/config/next-config-js/cacheComponents) enabled, dynamic content can stream within a prerendered shell. Inspect the route's configuration and output before choosing its cache policy.

> **Note:**
>
> Bypass HTML, RSC, and prefetch responses for the affected routes. Preserve the [required RSC and prefetch headers](https://nextjs.org/docs/app/guides/cdn-caching#what-you-must-preserve) and the `_rsc` query parameter when forwarding requests, then test both a full page load and client navigation.

## Troubleshooting

### The proxy still returns a cached HIT

Check the hostname, path, and locale match, then inspect rule order and any setting that overrides origin cache headers. For a response-header bypass, purge the old entry after confirming the new header is live. An effective request-time bypass should prevent the proxy from serving an old stored entry.

### Vercel reports MISS on every request

Repeat the same URL and request headers, then check Vercel's cache reason and logs. Confirm that the deployed route uses ISR and inspect the `Set-Cookie` response header, the `Authorization` request header, and effective cache-control directives. Since public SSR responses can also be cached explicitly, inspect the response policy when [diagnosing repeated misses](https://vercel.com/docs/caching/cdn-cache/debug-cache-issues).

### Revalidation succeeds but content stays stale

Compare the content returned directly by the intended Vercel deployment with the proxied response. If only the proxied response is stale and the proxy reports a cache hit, fix its bypass and purge the affected entries. Otherwise, inspect the revalidation target and regeneration logs. Keep the revalidation endpoint uncached and directed at the intended deployment. If you use rewrites, revalidate the actual route path.

### Data transfer rises after a route moves to ISR

More requests reach Vercel after the external cache is bypassed, which can increase data transfer. Compare request volume and response size before and after the change, then review the separate [ISR usage](https://vercel.com/docs/incremental-static-regeneration/limits-and-pricing) and [CDN usage](https://vercel.com/docs/manage-cdn-usage) metrics to identify the source of the increase.

## Prepare the ISR rollout with your agent

Use this prompt in your application's repository to have a coding agent check the route inventory and prepare the bypass configuration, tests, and rollout plan:

### Agent prompt

```txt
Use https://vercel.com/kb/fde/how-to-run-isr-on-vercel-behind-an-external-cdn-or-proxy to review my Next.js Pages Router project. An external CDN or proxy sits in front of Vercel. Identify the changes needed for Vercel to cache the converted ISR pages while the external proxy bypasses them.

1. Inspect the installed Next.js version, the actual next.config file, and the existing test setup. Identify converted pages using time-based or on-demand revalidation, including dynamic and catch-all routes. Inspect revalidation handlers as well as getStaticProps. List representative page URLs with their locale and basePath prefixes. Identify the related /_next/data requests that also need the proxy policy.

2. Propose Next.js source patterns that cover only the converted routes. Check every other route under a proposed prefix before using a wildcard, and identify any server-rendered exceptions. Preserve the config's module format, wrappers, existing rules, and rule order.

3. Determine my proxy's documented bypass mechanism and cache status values. Ask for provider-specific configuration that isn't in the repo. If the provider supports a dedicated cache-control response header, propose the required headers() rules. Otherwise, list the path-based bypass rules for me to configure externally. Don't set generic CDN-Cache-Control: no-store without first checking its effect on Vercel's cache. Don't change caching for unrelated routes.

4. Add a focused test using the existing test runner, or Node.js's built-in test runner if none is configured. Prefer testing response headers from the running production build. Verify the response status and expected content type as well as the bypass header. Include the setup and CI command. Maintain an explicit URL list unless the project already has a route inventory suitable for generating cases. State which routes the test covers; don't claim an unlisted route will be detected automatically. Don't assume the latest path-to-regexp package matches Next.js source syntax.

5. Propose scripts/verify-isr-cache.sh to accept a base URL and paths, issue GET requests, and print the HTTP status, proxy cache status, and x-vercel-cache. Preserve network errors and flag redirects, error responses, missing diagnostic headers, and documented proxy cache hits. Require the provider's documented bypass behavior, allow bounded retries for regeneration, and do not require HIT on exactly the second request. Ask for missing provider header names and value meanings.

6. Print a rollout and rollback checklist. Check CNAME, A, and AAAA records and confirm the HTTP request path before changes. Distinguish activating a proxy-side bypass before promotion from deploying a response header before purging. Before rollback, retain the bypass header in the rollback release or activate a temporary proxy-side bypass. Include the converted page and data URLs in targeted purges, verification, and rollback checks. Add a separate authorized content-change and revalidation check through the public hostname. Don't deploy, change DNS, purge caches, or modify content.

Constraints: only propose changes to the existing Next.js config, the new test, and the new script. Don't change page or data-fetching code or add dependencies. Show me the proposed diff before applying it. Report any step that needs additional files or external configuration.
```

## Next steps

- Configure [cache-control headers](https://vercel.com/docs/caching/cache-control-headers) for Vercel and other CDNs.
  
- Inspect [Vercel cache statuses and reasons](https://vercel.com/docs/caching/cache-status).
  
- Understand how [ISR](https://vercel.com/docs/incremental-static-regeneration) stores pages and revalidates content.
  
- Check [reverse proxy requirements and Verified Proxy](https://vercel.com/docs/security/reverse-proxy).
  
- Configure [Cloudflare or another reverse proxy](https://vercel.com/kb/guide/can-i-use-a-proxy-on-top-of-my-vercel-deployment) in front of Vercel.

## Related resources

- [How to troubleshoot stale content returned from the Vercel CDN when using an external proxy or CDN](/kb/guide/how-to-troubleshoot-stale-content-returned-from-the-edge-network-when-using-an-external-proxy-or-cdn): Learn how to diagnose and fix stale content issues when using external proxies or CDNs with Vercel. Understand troubleshooting strategies, and configuration best practices to ensure fresh content delivery.

- [Using Cloudflare and other reverse proxies with Vercel](/kb/guide/can-i-use-a-proxy-on-top-of-my-vercel-deployment): General information about using an external proxy to serve a Vercel Deployment.

- [Caching audits: Five antipatterns that cost you performance and money](/kb/fde/caching-antipatterns): Five caching antipatterns from hundreds of Vercel technical audits: write amplification, deploy-wiped caches, spinner shells, and how to diagnose each.

- [Set up Speed Insights behind a reverse proxy with multiple Vercel projects](/kb/fde/speed-insights-behind-reverse-proxy): Configure Speed Insights and Web Analytics to collect data when a reverse proxy such as Akamai or Cloudflare routes one domain to several Vercel projects.

## More FDE Field Notes

- [How to improve Interaction to Next Paint (INP) on Vercel](/kb/fde/improve-inp-on-vercel): Find the routes and elements behind a poor INP in Speed Insights, fix the slow parts in your Next.js app, and confirm the result with field data.

- [Set up Speed Insights behind a reverse proxy with multiple Vercel projects](/kb/fde/speed-insights-behind-reverse-proxy): Configure Speed Insights and Web Analytics to collect data when a reverse proxy such as Akamai or Cloudflare routes one domain to several Vercel projects.

- [Caching audits: Five antipatterns that cost you performance and money](/kb/fde/caching-antipatterns): Five caching antipatterns from hundreds of Vercel technical audits: write amplification, deploy-wiped caches, spinner shells, and how to diagnose each.

## Reference Architecture

Choose a stack and work through the decisions behind it, with curated documentation, guides, templates, and courses to help you build.

- [Agent stack](/kb/architecture/agents): Build and operate agents with models, tools, and durable workflows.
- [Web applications](/kb/architecture/web): Choose rendering, data, authentication, and caching approaches.
- [Backends](/kb/architecture/backends): Choose a runtime, connect services, and run background work.

[Browse all stacks](/kb/architecture)

## Build with prompts

Build an app, extend an agent, or improve your project with ready-to-use prompts for your coding agent.

[Browse the prompt library](/kb/prompts) · [Read the Markdown index](/kb/prompts.md)
