Why a dynamic QR code must redirect with a 302, never a 301

A permanent redirect sounds right for a printed code that never changes. It is the one choice that quietly breaks the whole point of a dynamic code.

By The QRtoMany team4 min read

A dynamic QR code is a short link printed as a pattern. The printed part never changes: it always encodes the same short URL. What changes is where that URL sends people, and you change it in a dashboard long after the ink is dry.

That makes the choice of HTTP redirect more important than it looks. There are two families of redirect, and only one of them lets a dynamic code keep its promise.

Permanent versus temporary

When a browser asks for the short URL, the server answers with a status code and a Location header naming the destination.

  • 301 Moved Permanently and 308 Permanent Redirect say: this address has moved for good, so go straight to the new one next time.
  • 302 Found and 307 Temporary Redirect say: for now, go over there, and ask me again next time.

The printed code really is permanent, and the short URL in it will never change. So a 301 can feel like the more correct, more "SEO-friendly" answer. It is the most damaging mistake a dynamic QR service can make.

What a 301 does to a printed code

Browsers are allowed to cache a permanent redirect, and they do, often with no expiry at all. So do some proxies and in-app browsers. After one scan, the phone may never ask the short link again: it jumps straight to the destination it remembers.

Now picture the code on a restaurant menu. In March the code points to the spring menu. In June the restaurant changes it to the summer menu in the dashboard. Everyone who scanned in March, on the same phone, still gets the spring menu, because their browser is no longer asking. The dashboard shows the new destination, the scan counts look normal, and a regular customer is reading last season's prices.

There is no fix from our side. We cannot reach into a phone and clear its cache, and the phone never contacts us again, so we cannot even tell it happened. Nothing else in a dynamic code's design can undo it.

What we send instead

A gated code, a deep link with something to try, or a warning or state page serves an HTML page first rather than a redirect. But every redirect we send for a scan is a 302 with Cache-Control: no-store — never a 301 or 308:

HTTP/1.1 302 FoundLocation: https://example.com/summer-menuCache-Control: no-store

The 302 tells the browser this redirect is for now. no-store tells it, and anything between it and us, not to keep a copy. Every scan comes back to us and gets the destination as it is at that moment. That is what makes the rest of the product work:

  • a published destination change takes effect within about a minute, for everyone;
  • routing rules, by device, country, language or time of day, are decided afresh on every scan;
  • an A/B test can move traffic to the winning page on codes already in circulation;
  • scan counts see every scan, not only each phone's first one.

The rule is enforced in our code, not just written down. The service that answers scans is built with a lint rule that rejects a permanent redirect status, so a well-meaning change cannot bring one in by accident.

"But what about SEO?"

The worry behind the 301 habit is that search engines pass ranking signals through permanent redirects and not temporary ones. That matters for a page that has moved. It does not matter here: nobody searches for the short link on a beer label, and the destination page ranks on its own merits. A dynamic code's short link is a routing layer, and a routing layer has to stay in the path.

The cost, and why it is worth it

Answering every scan fresh means the scan has to reach a server every time. That is why the scan path is built to be fast and very hard to break. It runs at the network edge close to the scanner, and it reads a precompiled copy of each code's routing rather than querying a database, so even a full database outage leaves every printed code resolving.

If you use another dynamic QR service

You can check which redirect it uses with any command-line HTTP client, for example curl -I followed by the short link, and look at the first line of the reply. A 301 or 308 there means scanners' browsers may stop seeing your changes.

A printed code cannot be recalled, and the redirect is the one thing between that print run and every change you will ever make. It should always be a 302.

About the author

The QRtoMany team

We build QRtoMany, a dynamic QR code service designed around one fact: a printed code can't be recalled. These posts are written from what we have built, and the numbers in them come from the product itself.

Try the routing on your own codes

Create a free account to get started, then request Pro to route your own codes — or make a static code with no account at all.

All posts
Why a dynamic QR code must redirect with a 302, never a 301 · QRtoMany