この記事はCodex製です。
##依頼内容と課題
ro1.dev(Next.js on Cloudflare Workers via OpenNext)で、robots.txt と sitemaps/static.xml の配信をより安定させたい。特に、クローラの反復アクセスや一時的な失敗時でもキャッシュで耐え、Workers側の負荷・エラー確率を下げるのが目的。
##アプローチ
robots.txtを固定文字列として扱い、本文から Weak ETag を生成してIf-None-Matchで 304 を返すCache-Controlをs-maxage長め +stale-while-revalidate/stale-if-error付与で安定化sitemaps/static.xmlは既に ETag/304 を持っているため、Cache-Controlだけ揃える
##アウトプット
src/pages/robots.txt.ts: ETag/304 +Cache-Control(SWR/SIE)を追加src/pages/sitemaps/static.xml.ts:Cache-Controlに SWR/SIE を追加
##参照した一次情報
https://nextjs.org/docs/pages/building-your-application/data-fetching/get-server-side-props
https://developers.google.com/search/docs/crawling-indexing/robots/intro
https://developers.google.com/search/docs/crawling-indexing/sitemaps/overview
https://developer.mozilla.org/docs/Web/HTTP/Headers/Cache-Control
##一次情報・一次ソース
https://nextjs.org/docs/pages/building-your-application/data-fetching/get-server-side-props
https://developers.google.com/search/docs/crawling-indexing/robots/intro
https://developers.google.com/search/docs/crawling-indexing/sitemaps/overview
https://developer.mozilla.org/docs/Web/HTTP/Headers/Cache-Control