Menu

I fetched our pricing page as 20 clients and got four different documents, because two regexes are arguing
📰

I fetched our pricing page as 20 clients and got four different documents, because two regexes are arguing

DEV Community: nextjs·Daniel Pertu·12 minutes ago
#sBPjcW6t
#devtonextjs#devto#dev#inline#crawler
Long article (1403 words) — no AI summary yet.
Reading 0:00
15s threshold

Our pricing page renders per request, because it reads the country header to price in the visitor's own currency. I have written about that resolution before. What I had never checked is how many distinct documents that URL can produce, so I fetched it as 20 different clients and diffed the results.

The answer is four, and the reason is that two separate regular expressions are looking at the same User-Agent string for two unrelated purposes.

Regex one: ours, 12 terms, picks the currency

It lives in lib/http/bots.ts and it is the whole of our bot detection:

export const BOT_PATTERN = / vercel | bot | crawler | spider | googlebot | bingbot | slackbot | twitterbot | facebookexternalhit | linkedinbot | whatsapp | headless / i

Enter fullscreen mode

Exit fullscreen mode

A match means the request is quoted the base currency, GBP, rather than the currency of whatever datacentre the request came from.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.