← All writing

· 4 min read

Cache Components, AVIF and llms.txt: performance and SEO for a farm-equipment catalog

A catalog site lives or dies on search and on mobile load time. These are the caching profiles, image settings and SEO plumbing behind celesa.com.ar, and the reasoning behind each number.

A farmer looking for a seeder usually starts on a phone, on a rural connection, with a search engine. That makes two things matter more than anything else on the CELE site: how fast the first screen appears, and whether the catalog can be found and understood by crawlers. Most of the work in the repo that is not features is about those two.

A product detail page: gallery first, then the description

Caching with names, not guesses

The app runs Next.js 16 with Cache Components (cacheComponents: true) and partial prerendering, plus partial prefetching so one app shell per route is shared across links. Public data is read through "use cache" functions, and every cache lifetime comes from a small set of named profiles in next.config.ts:

Profile Stale Revalidate Expire Used for
content 5 min 1 day 30 days Catalog, CMS text and images, news, dealers
permissions 1 min 1 hour 1 day Per-user permission sets
mailbox 30 s 1 min 5 min IMAP inbox listings

The comments next to each profile explain the reasoning, which is the part worth copying.

content has a very long window because it only changes through admin actions that call updateTag(...), so it is invalidated on every edit and expiry by time is a backstop. The one-day revalidate exists purely so out-of-band changes, such as a reseed script that bypasses the actions, still show up within a day.

permissions is deliberately short. A past bug left admins without new permissions after a reseed because a cache was never invalidated. A one-hour revalidate means that failure now heals itself.

mailbox exists because the inbox client polls every 30 seconds, and opening a fresh IMAP login per poll is slow and gets throttled by shared hosts. The cache absorbs the polling.

React's request-scoped cache() handles a different job: deduplicating identical reads inside a single render, such as the current user. It is never used for mutations or as a global cache.

Images are where the bytes are

The catalog is photographs of orange machines, so image settings dominate the page weight:

  • AVIF first, WebP fallback. AVIF is meaningfully smaller at the same quality, and the extra encoding cost is paid once and then served from the CDN.
  • Custom breakpoints. The default device sizes jump from 1200 to 1920, so a typical 1335 px laptop downloaded the 1920 px variant of a full-width hero. PageSpeed flagged it. Adding 1366 and 1536 lets those screens pick a right-sized file, and a 672 bucket keeps common phone renders from being promoted to the heavier 750 px variant.
  • A whitelist of qualities. Next 16 rejects any quality that is not listed, so the config lists the exact steps in use: lower values for full-bleed heroes and mobile catalog cards, higher ones for detail pages where a buyer inspects the photo.
  • Seven-day optimizer cache. Source images only change through admin uploads to fresh URLs, so long caching is safe.

One more rule from the repo's working notes: CMS media, including video posters, must go through the image optimizer, never raw Blob URLs, and <Image> never gets an empty src.

The stylesheet is inlined into the first HTML (inlineCss). The comment records the motivation: mobile PageSpeed was waiting about 740 ms on a 35 KiB render-blocking stylesheet, and the extra bytes in the HTML cost less than the extra round trip. The React Compiler is on, and the faster Rust version of it was deliberately shipped as its own last change so it could be reverted without touching anything else.

SEO that a crawler can read

Search metadata is generated, not typed. Helpers under lib/seo build page metadata and JSON-LD structured data for products and news. Two details matter:

  • Filters stay indexable. The catalog's category filters (/productos?categoria=sembradoras) produce their own titles and descriptions from the search params, without opting the whole route out of prerendering.
  • No fake review markup. Product metadata is written so that it never emits invented offers or ratings. Structured data that lies is worse than none.

robots.txt is explicit. In production it lists the public paths that should be indexed (home as /$, the catalog and its children, news, company, contact, legal pages) and disallows the admin, API, login, account and test routes. Anywhere that is not production, including every preview deployment, gets Disallow: / so staging copies never compete with the real site. A sitemap is generated alongside it.

The footer and sitemap-style link structure at the bottom of every page

A file for AI agents

The site also serves /llms.txt, following the llmstxt.org convention: a title, a short summary, then linked sections for products, news and dealers. It is assembled from the same cached readers as the public pages, tagged with the same cache tags, so when a product changes in the admin the file changes with it. The cost is near zero, and it gives an assistant answering "which seeder fits 24 rows at 35 cm" a clean source instead of a scraped page.

Proving navigation stays fast

Instant navigation is checked in Playwright against a production build, not assumed. There are specs for public and admin navigation flows, and the project's rule is to validate with a build and the end-to-end suite before deploying anything that could break production.

None of this is exotic. It is a catalog that decided its cache lifetimes on purpose, shipped fewer pixels, and told crawlers exactly what to read.