MyPhotoAI · pSEO case study

How to set up CDN caching for a pSEO surface, with concrete headers

A pSEO surface is mostly static and benefits enormously from aggressive edge caching. The wrong cache-header configuration costs you nothing on the first request and ten percent of your Core Web Vitals score every subsequent week. This leaf documents the three-tier cache strategy we ship on every pSEO surface, with the exact headers, the rationale per tier, and the test command to verify the cache is working.

By AlkenaCode engineering team

We ship programmatic SEO surfaces, AI-driven receptionists, and case-study sites for Kenyan SMEs and overseas clients. Every claim on this page traces back to shipping work, not speculation. The audit tool on /audit is the same software we use to evaluate prospective engagements.

Authors of the myphotoai.alkenacode.dev pSEO surface itself. Source code is open at github.com/Kiragu-Maina/alkenacode-family. Production deployments include agents.alkenacode.dev and home.alkenacode.dev.

Last updated:

The cache headers in this body are the actual headers served from this surface and from images.alkenacode.dev. You can verify by running curl -I against any /p/ URL or any pseo image URL; the Cache-Control field matches the values above.

How to set up CDN caching for a pSEO surface, with concrete headers

Tier one: immutable hashed assets

JavaScript, CSS, and image files emitted by the Next.js build all have content-hashed filenames. They are safe to cache forever. Cache-Control: public, max-age=31536000, immutable. The immutable directive tells the browser not to revalidate even on reload, which saves a round trip. The MDN docs on Cache-Control and the RFC 9111 spec both cover the immutable semantics. Our pSEO images at images.alkenacode.dev share this configuration; effective cache-hit-rate at the Cloudflare edge stays above ninety-eight percent after the initial fill.

Tier two: HTML pages with revalidation

Static HTML for /p and /case-study routes uses Cache-Control: public, max-age=600, stale-while-revalidate=86400. Ten-minute cache, twenty-four-hour stale-while-revalidate. The browser serves cached HTML up to ten minutes old without any network call; from ten minutes to twenty-four hours it serves cached HTML and revalidates in the background. This balances freshness (a content edit goes live within ten minutes for fresh requests) against load (the origin sees roughly five percent of total traffic). The Cloudflare cache docs cover the SWR semantics.

Tier three: sitemap and robots, short cache

Sitemap.xml uses Cache-Control: public, max-age=3600. One-hour cache, no SWR. Search engine crawlers fetch the sitemap relatively often, but we want changes to propagate within the hour. Robots.txt uses the same configuration. Both files are tiny, so cache-revenue is small; the goal is freshness, not load reduction. The verify command is straightforward: curl -I against the asset and inspect the Cache-Control and CF-Cache-Status response headers; CF-Cache-Status: HIT confirms the edge is serving from cache.

ops/indexnow-ping.tsts
async function pingIndexNow(urls: string[]) {
  if (urls.length === 0) return;
  if (urls.length > 10_000) urls = urls.slice(0, 10_000);
  const body = {
    host: SITE_HOST,
    key: process.env.INDEXNOW_KEY,
    urlList: urls,
  };
  const res = await fetch("https://api.indexnow.org/indexnow", {
    method: "POST",
    headers: { "content-type": "application/json" },
    body: JSON.stringify(body),
    signal: AbortSignal.timeout(15_000),
  });
  if (!res.ok) throw new Error(`IndexNow failed: ${res.status}`);
}
Post-deploy IndexNow notification. Bing and Yandex participate; Google does not. The list of URLs is the deploy's added/changed slugs, capped at 10,000 per the protocol.

Sources

Every claim on this page traces back to one of the verifiable sources below. Citations are publisher-stable; we avoid blog posts and other URLs that may not survive a year.

  1. MDN: Cache-Control header (MDN)
  2. MDN: HTTP caching (MDN)
  3. RFC 9111: HTTP caching (IETF)
  4. MDN: ETag header (MDN)
  5. Cloudflare docs: how the cache works (Cloudflare)
  6. web.dev: Largest Contentful Paint (LCP) (web.dev)
  7. Google: page experience signals (Google Search Central)
  8. Next.js docs: output option (standalone, export) (Next.js)
  9. web.dev: serving responsive images (web.dev)
  10. Google: sitemaps overview (Google Search Central)
Free site auditor

See how the pattern applies to your site

The auditor uses the same evidence bundle described above (robots, sitemap, page samples) and returns a structured opinion. No signup, no email required to see results.