DELTAWEB
All posts
Technical SEO

Edge SEO: Managing hreflang and Redirects at the CDN Layer

hreflang headers, redirects and language-based cache keys with CDN workers and edge rules: which jobs belong at the edge and which stay on the origin?

Edge SEO: Managing hreflang and Redirects at the CDN Layer
12 minReading time
Arif KuruAuthor

Open any product page of your site in your browser's developer tools, select the first HTML request in the network tab and read the response headers line by line. If you find a Link header your application never generates, the trace of a redirect rule or a line reporting cache status, part of your site's SEO behaviour is no longer decided on the server but at the CDN layer. As part of our guide to crawling, indexing and rendering on multilingual sites, this post looks at the approach called edge SEO through the lens of hreflang and redirects: what makes sense at the edge, what is safer to leave on the origin server, and who should own that decision.

What edge SEO covers

Edge SEO means making changes that affect search engine signals not in the application itself, but in the network layer between the request and the origin server. In practice that layer is a CDN. Most CDN providers now offer small scripts that can modify requests and responses (usually called "workers" or "edge functions") as well as rules defined without code. With these tools you can add response headers, inject tags into HTML, rewrite URLs, return redirects and change the cache key. Features and pricing differ between providers and change over time, so check your provider's current documentation before designing a setup.

The appeal is speed. A rule can go live within minutes, without touching an old CMS or waiting in the development queue. On sites where access to the source code is difficult, the edge layer is sometimes the only practical point of intervention. We discussed edge and serverless options on the hosting side in edge hosting and serverless for export websites; the topic here is not hosting but the SEO impact of rules placed in front of an existing site.

The same speed brings an equal amount of blindness. A change made at the edge does not appear in the application's repository, does not pass code review and does not run in the local development environment. What the page source shows and what reaches the search engine can drift apart, and most risks of edge SEO come from that gap.

Adding hreflang headers at the edge

Google supports three ways of providing hreflang information: link elements in the HTML, the Link field in the HTTP response header and the XML sitemap. At the edge the most natural route is the HTTP header, because adding one line to the header section is enough without parsing the HTML. For non-HTML files such as PDFs it is the only option anyway. For the details and syntax of the supported methods, check Google Search Central for the current state.

The real difficulty of generating hreflang at the edge is not syntax but where the mapping data comes from. A worker cannot know on its own which German and English pages correspond to a Turkish product page. Either the URL structure must be fully predictable (the same slug in every language, only the language folder differs) or there must be a mapping table the worker can read. The first case is simple on paper, but on most export sites slugs are translated per language, so the German URL is not simply the Turkish URL with a different folder. In the second case a copy of the translation relationships held in the CMS starts living at the edge, and the two sources must stay in sync.

When the mapping table goes stale, the picture is familiar: a newly added language version is missing from the cluster, a deleted page is still listed as an alternate, return links stay one-sided. Generated at the edge, these errors are noticed later, because someone reading the source code does not look for them there. If the same page carries both HTML annotations and an edge-injected header, and the two say different things, the search engine receives a conflicting signal. If you decide to add hreflang at the edge, remove the tags the application generates, or at least guarantee that both are fed from exactly the same source.

Modern server rack lit with blue lights in a secure data centre
Photo: panumas nikhomkhai / Pexels

Redirects at the edge

Redirects are among the SEO tasks best suited to the edge layer. Permanently sending hundreds of old URLs to their new counterparts after a migration, enforcing letter case or trailing slash consistency, choosing between www and the bare domain: such rules can be applied without looking at page content. A 301 or 308 returned at the edge never reaches the origin server, which reduces server load and response time. These deterministic redirects, rules that give every visitor and every crawler the same result, can run safely at the edge.

The trouble starts when a redirect begins to vary with the properties of the request. Automatically sending visitors to a language folder based on the country guessed from their IP address, or on the browser's Accept-Language header, is a feature CDNs offer with little effort. Google, however, generally advises caution with automatic redirects based on a user's perceived language, because they can stop users from reaching the version they want and make it harder for crawlers to see every language version. Check Google's documentation on multilingual and multi-regional sites for the current recommendations. The safer approach is to show the user a language suggestion and leave the choice to them.

The second risk of edge redirects is a clash with the application's own redirects. If the CDN redirects a URL to its trailing-slash form while the application redirects the same URL back to the version without the slash, the result is a loop. We covered these problems in redirect loops when switching language. The rule is simple: each type of redirect should be defined either at the edge or in the application, never in both.

Cache keys by language

When a CDN caches a response, it stores it under a key. The default key usually consists of the hostname and path. If language versions live on different URLs (for example /de/ and /en/ folders), each language already has its own key and nothing extra is needed. This is one of the most concrete benefits of carrying the language in the URL: the cache, the browser and the search engine all receive the same content when they see the same address.

The problem appears in setups where the same URL returns content in different languages. If the language is read from a cookie, the Accept-Language header or the IP location, that information has to be added to the cache key; otherwise the language of the first visitor is written to the cache and served to everyone after. Once language is part of the key, the cache holds several copies of the same URL, and which copy a search engine crawler receives depends on the headers it sends. For the details of this tangle, see our post on hreflang with CDNs and caching and the Vary header.

When you add a header at the edge, you also need to know whether it is added on every request or stored together with the cached response, and when stale headers are purged after the mapping table changes. If nobody knows, a fix is made, looks fixed, and old copies in the cache keep sending the wrong signal for a long time.

Origin vs edge compared

The difference between doing the same job on the origin server or at the edge is less about technical capability than about visibility, ownership and reversibility. The table below summarises the typical differences for hreflang and redirects; some rows may turn out differently on your own infrastructure.

AspectOrigin (application)Edge (CDN layer)
Data sourceTranslation relationships read directly from the CMSNeeds a mapping table or URL pattern; the copy must stay in sync
VisibilityIn the code repository and the page sourceIn a separate dashboard or script, may not show in the source
Speed of changeTied to the development and release cycleCan go live within minutes
TestabilitySame behaviour locally and on stagingOften observable only live or in a dedicated environment
Redirect performanceThe request travels to the serverResponse returns at the edge, server load drops
Request-dependent responsesControlled by application logicSplitting by IP and header is easy, cloaking risk grows
RollbackTracked through version controlDepends on the provider's rule history, hard if undocumented

What the table shows is that the edge layer has the advantage in speed and performance, while the origin wins on accuracy and traceability. Weighing these two axes separately gives a sounder answer than general beliefs about which approach is more modern.

Close-up of fibre optic strands glowing in blue and green
Photo: Atlantic Ambience / Pexels

Risks of edge rules

The risks of edge SEO are more often organisational than technical: the rule is a few lines long, but who wrote it and why is forgotten.

Varying by IP and cloaking

CDNs easily read the country a request comes from, the user agent and known crawler IP ranges. Returning different content based on this information is technically a condition of a few lines. Showing a search engine crawler different content from users, however, can fall under what Google's spam policies define as cloaking. Good intentions do not remove that risk. We discussed the line between location-based content and cloaking in detail in IP-based content and where cloaking begins. The basic principle for edge rules is that no condition distinguishing a crawler from a user should change the content or the hreflang signal. Check the official source for the current text of the policy.

Debugging is harder

When an unexpected redirect or a faulty hreflang header shows up on a page, the first question is which layer produced it. If the application, the server configuration, a CDN rule and a worker script can all modify the same response, finding the source becomes guesswork. Having every edge rule that changes a response add a header identifying itself (a line stating which rule and which version ran, for example) makes debugging much easier. Keep such headers limited to the rule name and version so they do not leak sensitive information.

Unclear ownership

The CDN account often belongs to IT or the hosting company, the code repository to the developer, and SEO decisions to the marketing team. Edge SEO sits where these three areas overlap and belongs fully to none of them. When an agency changes, the rules stay in place but the person who wrote them leaves; the new team discovers them only when something breaks. Every edge rule needs an owner and a written rationale; that protection outlives the rule itself.

Rule drift

Rule drift is the slow divergence of edge logic from the real state of the application. The site adds a new language but the mapping table is not updated; a product category moves but the old redirect rule still points to the previous target; the application starts generating its own hreflang tags while the edge header keeps running. These small inconsistencies pile up into conflicting signals. The way to prevent drift is to tie edge rules to the application's release process and add the question "is there an edge rule affecting this?" to the checklist for every major change.

When to keep logic in origin

Some jobs can be done at the edge yet belong on the origin. First among them are content-dependent decisions. Which language versions of a page actually exist, which are published, which are drafts and which are noindex is information held in the CMS. The hreflang cluster depends on it; keeping a copy at the edge splits the truth across two sources. If a modern CMS or framework can generate hreflang from page data, generating it again at the edge rarely adds anything.

The second group is decisions that directly shape user experience. Where the language switcher leads, what a user sees on a page with no translation, which category a removed product redirects to: these require knowing the context of the page, and the edge layer only knows as much as the data it is given. The third group is anything not meant to be temporary. A fix made at the edge should be treated as a bridge until the application is fixed, and removed once the permanent solution moves to the origin.

The jobs that make sense at the edge are typically bulk redirects after a migration, normalisation at domain and protocol level, temporary hreflang headers on a platform whose source code you cannot reach, and Link headers for non-HTML files. What they have in common is that they are independent of page content and produce the same result for everyone.

Auditing edge rules

On a site that uses edge SEO, a regular audit starts by putting two realities side by side: the response the application produces and the response that reaches the user. The practical way is to request a few representative pages both directly from the origin (bypassing the CDN, if your infrastructure allows it) and through the normal route, and to compare headers and HTML. Every difference is the trace of an edge rule, and each one should have an entry in your list.

The second step is to request the same page under different conditions: different Accept-Language values, different user agents and, if possible, from different countries. If the content or the hreflang header changes with these conditions, ask whether that change is deliberate and documented. Google's URL Inspection tool is a useful checkpoint for seeing how Google fetched a page; check the official source for the current scope of what it shows.

The third step is keeping a rule inventory. For every edge rule, what it does, why it was added, who is responsible, when it was added and under what condition it will be removed should be written down in one place. If edge rules can be put under version control like code, through the provider's configuration files or infrastructure-as-code tooling, the inventory builds itself and changes pass through review. Treat every SEO change at the edge like a release: try it on a limited set of paths first, watch the results, then widen it.

Could you explain what a rule running at your edge does today using only your documentation, without asking the person who wrote it?

FAQ

Frequently Asked Questions

  • Does Google accept hreflang sent as an HTTP header from the CDN layer?

    Yes, Google also accepts hreflang information in the Link field of the HTTP response header. Whether the header is added at the edge or on the server makes no difference; what matters is correct syntax and a consistent cluster. Check Google Search Central for the current state of the supported methods.

  • Is it a problem to give hreflang both in HTML and in an edge header?

    If both carry exactly the same information it is usually not a problem, but the moment they differ you send a conflicting signal. Maintenance effort also doubles. Choosing one method and removing the other is safer.

  • Should I redirect visitors to a language folder at the edge based on IP?

    Showing a language suggestion is a safer approach than an automatic redirect. Google advises caution with automatic redirects based on perceived language, and since crawlers may fetch mostly from certain countries, some language versions can stay hidden. Check the official documentation for the current recommendation.

  • Are redirects made at the edge treated differently from server redirects?

    A search engine only sees the status code and the target URL; it does not distinguish which layer produced the redirect. A 301 or 308 returned at the edge sends the same signal as one from the server. The difference lies in maintenance and the risk of clashes.

  • Do I need to change the cache key if language versions use separate URLs?

    In most cases no, because the path is already part of the cache key and each language gets its own copy. Extra configuration is needed when the same URL returns different languages depending on a cookie or header. That is one more reason why carrying the language in the URL simplifies caching.

  • How can I find out what edge rules are doing on my site?

    Request a few representative pages both directly from the origin and through the normal route, then compare headers and HTML. Every difference is the trace of an edge rule. Rules that add a header identifying themselves make this comparison much easier.

  • Who should own edge rules?

    Every rule should have a named owner and a written rationale. In practice the SEO or marketing team makes the SEO decision and the infrastructure team implements it, but the inventory lives in one place everyone can reach. When an agency changes, that inventory should be part of the handover.

  • Does an SEO fix made at the edge count as a permanent solution?

    In most cases no; it should be treated as a bridge until the application is fixed. Content-dependent decisions are managed more accurately over the long term in the CMS and on the origin. Once the permanent fix moves to the origin, remove the edge rule.

Related Articles

No comments yet

Leave a Comment