[{"data":1,"prerenderedAt":2260},["ShallowReactive",2],{"article-alternates":3,"article-\u002Fru\u002Ftech\u002Fedge-ssr-snizit-personalizacija-latenciju-40ms":13},{"i18nKey":4,"paths":5},"tech-003-2026-05",{"de":6,"en":7,"es":8,"fr":9,"it":10,"ru":11,"tr":12},"\u002Fde\u002Ftech\u002Fedge-ssr-personalisierung-latenz-40ms","\u002Fen\u002Ftech\u002Fedge-ssr-personalization-40ms-latency","\u002Fes\u002Ftech\u002Freducir-latencia-personalizacion-edge-ssr-40ms","\u002Ffr\u002Ftech\u002Fedge-ssr-personalizasyon-latency-40ms","\u002Fit\u002Ftech\u002Fedge-ssr-personalization-40ms","\u002Fru\u002Ftech\u002Fedge-ssr-snizit-personalizacija-latenciju-40ms","\u002Ftr\u002Ftech\u002Fedge-ssr-ile-personalizasyon-latencysini-40msye-dusurmek",{"_path":11,"_dir":14,"_draft":15,"_partial":15,"_locale":16,"title":17,"description":18,"publishedAt":19,"modifiedAt":19,"category":14,"i18nKey":4,"tags":20,"readingTime":26,"author":27,"body":28,"_type":2254,"_id":2255,"_source":2256,"_file":2257,"_stem":2258,"_extension":2259},"tech",false,"","Снижение задержки персонализации Edge SSR до 40ms","Архитектура хранилища KV с Cloudflare Workers и Vercel Edge позволяет снизить латентность серверной персонализации ниже 40 миллисекунд.","2026-05-12",[21,22,23,24,25],"edge-computing","ssr","personalization","cloudflare-workers","vercel-edge",9,"Roibase",{"type":29,"children":30,"toc":2242},"root",[31,39,46,51,56,72,78,83,535,540,547,552,659,672,678,683,688,727,887,900,905,911,916,924,929,1170,1175,1181,1186,1197,1450,1455,1465,1685,1698,1834,1839,1845,1850,1858,1863,2120,2125,2149,2162,2168,2173,2226,2231,2236],{"type":32,"tag":33,"props":34,"children":35},"element","p",{},[36],{"type":37,"value":38},"text","Традиционный серверный рендеринг на origin-серверах означает латентность 200–400ms в среднем. Если кэшировать HTML на CDN edge, это сократится до 20–50ms, но персонализация потеряется. Edge SSR разрывает эту дилемму: получаешь одновременно и персонализацию, и ответ менее чем за 40ms. Достигается это через edge runtime'ы вроде Cloudflare Workers и Vercel Edge в сочетании с распределённым хранилищем KV. Больше не нужно выбирать между кэшем и персонализацией — берёшь и то, и другое.",{"type":32,"tag":40,"props":41,"children":43},"h2",{"id":42},"почему-edge-ssr-критичен-сейчас",[44],{"type":37,"value":45},"Почему Edge SSR критичен сейчас",{"type":32,"tag":33,"props":47,"children":48},{},[49],{"type":37,"value":50},"С 2025 года метрика INP браузера Chrome вошла в Core Web Vitals. Ответ сервера более 200ms сам по себе способен разрушить INP. Каждый запрос к origin добавляет 150–300ms из-за физического расстояния и cold start. Edge runtime убирает эту преграду: код выполняется в ближайшем к пользователю POP'е (Point of Presence), данные из KV в том же регионе приходят за 5–15ms.",{"type":32,"tag":33,"props":52,"children":53},{},[54],{"type":37,"value":55},"Это не только скорость. Персонализация теперь не требует запроса к origin. Сегмент пользователя, предпочтения, статус корзины хранятся в edge KV. Когда приходит запрос, функция на edge извлекает эти данные и тут же рендерит HTML. Origin-сервер используется только для операций записи и сложных вычислений.",{"type":32,"tag":33,"props":57,"children":58},{},[59,61,70],{"type":37,"value":60},"При работе с платформами вроде Shopify эта архитектура особенно важна. Шаблоны Liquid рендерятся на origin и отнимают 300–600ms на страницу. С Edge SSR HTML становится composable: одна edge-функция рендерит карточку товара, другая инжектирует информацию о корзине. Общая латентность падает ниже 40ms. Подробнее об интеграции см. ",{"type":32,"tag":62,"props":63,"children":67},"a",{"href":64,"rel":65},"https:\u002F\u002Fwww.roibase.com.tr\u002Fru\u002Fheadless",[66],"nofollow",[68],{"type":37,"value":69},"Headless Commerce",{"type":37,"value":71},".",{"type":32,"tag":40,"props":73,"children":75},{"id":74},"cloudflare-workers-kv-ядро-архитектуры",[76],{"type":37,"value":77},"Cloudflare Workers + KV: ядро архитектуры",{"type":32,"tag":33,"props":79,"children":80},{},[81],{"type":37,"value":82},"Cloudflare Workers работает на основе V8 isolate. Для каждого запроса не создаётся новый контейнер, открывается JavaScript isolate. Это обходится в 0.5–2ms. Код Worker выглядит так:",{"type":32,"tag":84,"props":85,"children":89},"pre",{"code":86,"language":87,"meta":16,"className":88,"style":16},"export default {\n  async fetch(request, env) {\n    const url = new URL(request.url);\n    const userId = request.headers.get('CF-Connecting-IP') || 'anonymous';\n    \n    \u002F\u002F Извлечь сегмент пользователя из KV\n    const segment = await env.USER_SEGMENTS.get(userId);\n    \n    \u002F\u002F Рендерить список товаров в зависимости от сегмента\n    const products = segment === 'premium' \n      ? await fetchPremiumProducts() \n      : await fetchStandardProducts();\n    \n    const html = renderHTML(products, segment);\n    \n    return new Response(html, {\n      headers: { 'Content-Type': 'text\u002Fhtml; charset=utf-8' }\n    });\n  }\n};\n","javascript","language-javascript shiki shiki-themes github-dark",[90],{"type":32,"tag":91,"props":92,"children":93},"code",{"__ignoreMap":16},[94,117,158,193,250,259,269,314,322,330,367,390,413,421,448,456,479,508,517,526],{"type":32,"tag":95,"props":96,"children":99},"span",{"class":97,"line":98},"line",1,[100,106,111],{"type":32,"tag":95,"props":101,"children":103},{"style":102},"--shiki-default:#F97583",[104],{"type":37,"value":105},"export",{"type":32,"tag":95,"props":107,"children":108},{"style":102},[109],{"type":37,"value":110}," default",{"type":32,"tag":95,"props":112,"children":114},{"style":113},"--shiki-default:#E1E4E8",[115],{"type":37,"value":116}," {\n",{"type":32,"tag":95,"props":118,"children":120},{"class":97,"line":119},2,[121,126,132,137,143,148,153],{"type":32,"tag":95,"props":122,"children":123},{"style":102},[124],{"type":37,"value":125},"  async",{"type":32,"tag":95,"props":127,"children":129},{"style":128},"--shiki-default:#B392F0",[130],{"type":37,"value":131}," fetch",{"type":32,"tag":95,"props":133,"children":134},{"style":113},[135],{"type":37,"value":136},"(",{"type":32,"tag":95,"props":138,"children":140},{"style":139},"--shiki-default:#FFAB70",[141],{"type":37,"value":142},"request",{"type":32,"tag":95,"props":144,"children":145},{"style":113},[146],{"type":37,"value":147},", ",{"type":32,"tag":95,"props":149,"children":150},{"style":139},[151],{"type":37,"value":152},"env",{"type":32,"tag":95,"props":154,"children":155},{"style":113},[156],{"type":37,"value":157},") {\n",{"type":32,"tag":95,"props":159,"children":161},{"class":97,"line":160},3,[162,167,173,178,183,188],{"type":32,"tag":95,"props":163,"children":164},{"style":102},[165],{"type":37,"value":166},"    const",{"type":32,"tag":95,"props":168,"children":170},{"style":169},"--shiki-default:#79B8FF",[171],{"type":37,"value":172}," url",{"type":32,"tag":95,"props":174,"children":175},{"style":102},[176],{"type":37,"value":177}," =",{"type":32,"tag":95,"props":179,"children":180},{"style":102},[181],{"type":37,"value":182}," new",{"type":32,"tag":95,"props":184,"children":185},{"style":128},[186],{"type":37,"value":187}," URL",{"type":32,"tag":95,"props":189,"children":190},{"style":113},[191],{"type":37,"value":192},"(request.url);\n",{"type":32,"tag":95,"props":194,"children":196},{"class":97,"line":195},4,[197,201,206,210,215,220,224,230,235,240,245],{"type":32,"tag":95,"props":198,"children":199},{"style":102},[200],{"type":37,"value":166},{"type":32,"tag":95,"props":202,"children":203},{"style":169},[204],{"type":37,"value":205}," userId",{"type":32,"tag":95,"props":207,"children":208},{"style":102},[209],{"type":37,"value":177},{"type":32,"tag":95,"props":211,"children":212},{"style":113},[213],{"type":37,"value":214}," request.headers.",{"type":32,"tag":95,"props":216,"children":217},{"style":128},[218],{"type":37,"value":219},"get",{"type":32,"tag":95,"props":221,"children":222},{"style":113},[223],{"type":37,"value":136},{"type":32,"tag":95,"props":225,"children":227},{"style":226},"--shiki-default:#9ECBFF",[228],{"type":37,"value":229},"'CF-Connecting-IP'",{"type":32,"tag":95,"props":231,"children":232},{"style":113},[233],{"type":37,"value":234},") ",{"type":32,"tag":95,"props":236,"children":237},{"style":102},[238],{"type":37,"value":239},"||",{"type":32,"tag":95,"props":241,"children":242},{"style":226},[243],{"type":37,"value":244}," 'anonymous'",{"type":32,"tag":95,"props":246,"children":247},{"style":113},[248],{"type":37,"value":249},";\n",{"type":32,"tag":95,"props":251,"children":253},{"class":97,"line":252},5,[254],{"type":32,"tag":95,"props":255,"children":256},{"style":113},[257],{"type":37,"value":258},"    \n",{"type":32,"tag":95,"props":260,"children":262},{"class":97,"line":261},6,[263],{"type":32,"tag":95,"props":264,"children":266},{"style":265},"--shiki-default:#6A737D",[267],{"type":37,"value":268},"    \u002F\u002F Извлечь сегмент пользователя из KV\n",{"type":32,"tag":95,"props":270,"children":272},{"class":97,"line":271},7,[273,277,282,286,291,296,301,305,309],{"type":32,"tag":95,"props":274,"children":275},{"style":102},[276],{"type":37,"value":166},{"type":32,"tag":95,"props":278,"children":279},{"style":169},[280],{"type":37,"value":281}," segment",{"type":32,"tag":95,"props":283,"children":284},{"style":102},[285],{"type":37,"value":177},{"type":32,"tag":95,"props":287,"children":288},{"style":102},[289],{"type":37,"value":290}," await",{"type":32,"tag":95,"props":292,"children":293},{"style":113},[294],{"type":37,"value":295}," env.",{"type":32,"tag":95,"props":297,"children":298},{"style":169},[299],{"type":37,"value":300},"USER_SEGMENTS",{"type":32,"tag":95,"props":302,"children":303},{"style":113},[304],{"type":37,"value":71},{"type":32,"tag":95,"props":306,"children":307},{"style":128},[308],{"type":37,"value":219},{"type":32,"tag":95,"props":310,"children":311},{"style":113},[312],{"type":37,"value":313},"(userId);\n",{"type":32,"tag":95,"props":315,"children":317},{"class":97,"line":316},8,[318],{"type":32,"tag":95,"props":319,"children":320},{"style":113},[321],{"type":37,"value":258},{"type":32,"tag":95,"props":323,"children":324},{"class":97,"line":26},[325],{"type":32,"tag":95,"props":326,"children":327},{"style":265},[328],{"type":37,"value":329},"    \u002F\u002F Рендерить список товаров в зависимости от сегмента\n",{"type":32,"tag":95,"props":331,"children":333},{"class":97,"line":332},10,[334,338,343,347,352,357,362],{"type":32,"tag":95,"props":335,"children":336},{"style":102},[337],{"type":37,"value":166},{"type":32,"tag":95,"props":339,"children":340},{"style":169},[341],{"type":37,"value":342}," products",{"type":32,"tag":95,"props":344,"children":345},{"style":102},[346],{"type":37,"value":177},{"type":32,"tag":95,"props":348,"children":349},{"style":113},[350],{"type":37,"value":351}," segment ",{"type":32,"tag":95,"props":353,"children":354},{"style":102},[355],{"type":37,"value":356},"===",{"type":32,"tag":95,"props":358,"children":359},{"style":226},[360],{"type":37,"value":361}," 'premium'",{"type":32,"tag":95,"props":363,"children":364},{"style":113},[365],{"type":37,"value":366}," \n",{"type":32,"tag":95,"props":368,"children":370},{"class":97,"line":369},11,[371,376,380,385],{"type":32,"tag":95,"props":372,"children":373},{"style":102},[374],{"type":37,"value":375},"      ?",{"type":32,"tag":95,"props":377,"children":378},{"style":102},[379],{"type":37,"value":290},{"type":32,"tag":95,"props":381,"children":382},{"style":128},[383],{"type":37,"value":384}," fetchPremiumProducts",{"type":32,"tag":95,"props":386,"children":387},{"style":113},[388],{"type":37,"value":389},"() \n",{"type":32,"tag":95,"props":391,"children":393},{"class":97,"line":392},12,[394,399,403,408],{"type":32,"tag":95,"props":395,"children":396},{"style":102},[397],{"type":37,"value":398},"      :",{"type":32,"tag":95,"props":400,"children":401},{"style":102},[402],{"type":37,"value":290},{"type":32,"tag":95,"props":404,"children":405},{"style":128},[406],{"type":37,"value":407}," fetchStandardProducts",{"type":32,"tag":95,"props":409,"children":410},{"style":113},[411],{"type":37,"value":412},"();\n",{"type":32,"tag":95,"props":414,"children":416},{"class":97,"line":415},13,[417],{"type":32,"tag":95,"props":418,"children":419},{"style":113},[420],{"type":37,"value":258},{"type":32,"tag":95,"props":422,"children":424},{"class":97,"line":423},14,[425,429,434,438,443],{"type":32,"tag":95,"props":426,"children":427},{"style":102},[428],{"type":37,"value":166},{"type":32,"tag":95,"props":430,"children":431},{"style":169},[432],{"type":37,"value":433}," html",{"type":32,"tag":95,"props":435,"children":436},{"style":102},[437],{"type":37,"value":177},{"type":32,"tag":95,"props":439,"children":440},{"style":128},[441],{"type":37,"value":442}," renderHTML",{"type":32,"tag":95,"props":444,"children":445},{"style":113},[446],{"type":37,"value":447},"(products, segment);\n",{"type":32,"tag":95,"props":449,"children":451},{"class":97,"line":450},15,[452],{"type":32,"tag":95,"props":453,"children":454},{"style":113},[455],{"type":37,"value":258},{"type":32,"tag":95,"props":457,"children":459},{"class":97,"line":458},16,[460,465,469,474],{"type":32,"tag":95,"props":461,"children":462},{"style":102},[463],{"type":37,"value":464},"    return",{"type":32,"tag":95,"props":466,"children":467},{"style":102},[468],{"type":37,"value":182},{"type":32,"tag":95,"props":470,"children":471},{"style":128},[472],{"type":37,"value":473}," Response",{"type":32,"tag":95,"props":475,"children":476},{"style":113},[477],{"type":37,"value":478},"(html, {\n",{"type":32,"tag":95,"props":480,"children":482},{"class":97,"line":481},17,[483,488,493,498,503],{"type":32,"tag":95,"props":484,"children":485},{"style":113},[486],{"type":37,"value":487},"      headers: { ",{"type":32,"tag":95,"props":489,"children":490},{"style":226},[491],{"type":37,"value":492},"'Content-Type'",{"type":32,"tag":95,"props":494,"children":495},{"style":113},[496],{"type":37,"value":497},": ",{"type":32,"tag":95,"props":499,"children":500},{"style":226},[501],{"type":37,"value":502},"'text\u002Fhtml; charset=utf-8'",{"type":32,"tag":95,"props":504,"children":505},{"style":113},[506],{"type":37,"value":507}," }\n",{"type":32,"tag":95,"props":509,"children":511},{"class":97,"line":510},18,[512],{"type":32,"tag":95,"props":513,"children":514},{"style":113},[515],{"type":37,"value":516},"    });\n",{"type":32,"tag":95,"props":518,"children":520},{"class":97,"line":519},19,[521],{"type":32,"tag":95,"props":522,"children":523},{"style":113},[524],{"type":37,"value":525},"  }\n",{"type":32,"tag":95,"props":527,"children":529},{"class":97,"line":528},20,[530],{"type":32,"tag":95,"props":531,"children":532},{"style":113},[533],{"type":37,"value":534},"};\n",{"type":32,"tag":33,"props":536,"children":537},{},[538],{"type":37,"value":539},"Cloudflare KV реплицируется на 300+ POP'ах. Средняя латентность чтения — 12ms глобально. Запись распространяется через eventual consistency за 60 секунд. Поэтому в KV пишутся только редко изменяющиеся данные: настройки пользователей, маппинги сегментов, флаги функций. Часто изменяемые данные, например цены товаров, берутся из origin API и кэшируются на edge (Cache API с TTL 60 секунд).",{"type":32,"tag":541,"props":542,"children":544},"h3",{"id":543},"vercel-edge-vs-cloudflare-workers",[545],{"type":37,"value":546},"Vercel Edge vs Cloudflare Workers",{"type":32,"tag":33,"props":548,"children":549},{},[550],{"type":37,"value":551},"Vercel Edge Functions тоже использует V8 isolate, но сеть другая. Cloudflare имеет 300+ POP'ов, Vercel — около 15 региональных edge-локаций. Сравнение латентности (пользователь в Европе, origin в США):",{"type":32,"tag":553,"props":554,"children":555},"table",{},[556,585],{"type":32,"tag":557,"props":558,"children":559},"thead",{},[560],{"type":32,"tag":561,"props":562,"children":563},"tr",{},[564,570,575,580],{"type":32,"tag":565,"props":566,"children":567},"th",{},[568],{"type":37,"value":569},"Runtime",{"type":32,"tag":565,"props":571,"children":572},{},[573],{"type":37,"value":574},"Cold Start",{"type":32,"tag":565,"props":576,"children":577},{},[578],{"type":37,"value":579},"KV Read",{"type":32,"tag":565,"props":581,"children":582},{},[583],{"type":37,"value":584},"Total TTFB",{"type":32,"tag":586,"props":587,"children":588},"tbody",{},[589,613,636],{"type":32,"tag":561,"props":590,"children":591},{},[592,598,603,608],{"type":32,"tag":593,"props":594,"children":595},"td",{},[596],{"type":37,"value":597},"Origin SSR",{"type":32,"tag":593,"props":599,"children":600},{},[601],{"type":37,"value":602},"150ms",{"type":32,"tag":593,"props":604,"children":605},{},[606],{"type":37,"value":607},"N\u002FA",{"type":32,"tag":593,"props":609,"children":610},{},[611],{"type":37,"value":612},"380ms",{"type":32,"tag":561,"props":614,"children":615},{},[616,621,626,631],{"type":32,"tag":593,"props":617,"children":618},{},[619],{"type":37,"value":620},"Vercel Edge",{"type":32,"tag":593,"props":622,"children":623},{},[624],{"type":37,"value":625},"8ms",{"type":32,"tag":593,"props":627,"children":628},{},[629],{"type":37,"value":630},"22ms",{"type":32,"tag":593,"props":632,"children":633},{},[634],{"type":37,"value":635},"45ms",{"type":32,"tag":561,"props":637,"children":638},{},[639,644,649,654],{"type":32,"tag":593,"props":640,"children":641},{},[642],{"type":37,"value":643},"Cloudflare Workers",{"type":32,"tag":593,"props":645,"children":646},{},[647],{"type":37,"value":648},"1ms",{"type":32,"tag":593,"props":650,"children":651},{},[652],{"type":37,"value":653},"11ms",{"type":32,"tag":593,"props":655,"children":656},{},[657],{"type":37,"value":658},"28ms",{"type":32,"tag":33,"props":660,"children":661},{},[662,664,670],{"type":37,"value":663},"Преимущество Vercel — глубокая интеграция с экосистемой Next.js. Пишешь edge-функцию в ",{"type":32,"tag":91,"props":665,"children":667},{"className":666},[],[668],{"type":37,"value":669},"middleware.ts",{"type":37,"value":671},", запушиваешь в production, оркестрация на стороне Vercel. На Cloudflare нужно самостоятельно использовать Wrangler CLI и вручную связывать KV. Компромисс: больше контроля против более быстрого старта.",{"type":32,"tag":40,"props":673,"children":675},{"id":674},"архитектура-kv-pattern-записи-и-ревалидация",[676],{"type":37,"value":677},"Архитектура KV: pattern записи и ревалидация",{"type":32,"tag":33,"props":679,"children":680},{},[681],{"type":37,"value":682},"Eventual consistency KV — ограничение. Пользователь кликнул кнопку, предпочтение изменилось — это распространится на все edge за 60 секунд. В этот период разные POP'ы могут читать разные значения. Решение: после записи перенаправить на origin или выполнить оптимистичное обновление на клиенте.",{"type":32,"tag":33,"props":684,"children":685},{},[686],{"type":37,"value":687},"Пример flow'а:",{"type":32,"tag":689,"props":690,"children":691},"ol",{},[692,698,711,722],{"type":32,"tag":693,"props":694,"children":695},"li",{},[696],{"type":37,"value":697},"Пользователь нажимает переключатель \"Тёмный режим\"",{"type":32,"tag":693,"props":699,"children":700},{},[701,703,709],{"type":37,"value":702},"Клиент отправляет POST на ",{"type":32,"tag":91,"props":704,"children":706},{"className":705},[],[707],{"type":37,"value":708},"\u002Fapi\u002Fpreferences",{"type":37,"value":710}," (origin)",{"type":32,"tag":693,"props":712,"children":713},{},[714,716],{"type":37,"value":715},"Origin пишет в KV ",{"type":32,"tag":91,"props":717,"children":719},{"className":718},[],[720],{"type":37,"value":721},"user:123:theme = dark",{"type":32,"tag":693,"props":723,"children":724},{},[725],{"type":37,"value":726},"Origin вызывает Cloudflare API для немедленной ревалидации кэша:",{"type":32,"tag":84,"props":728,"children":730},{"code":729,"language":87,"meta":16,"className":88,"style":16},"\u002F\u002F На origin'е\nawait fetch(`https:\u002F\u002Fapi.cloudflare.com\u002Fclient\u002Fv4\u002Fzones\u002F${zoneId}\u002Fpurge_cache`, {\n  method: 'POST',\n  headers: { 'Authorization': `Bearer ${apiToken}` },\n  body: JSON.stringify({ files: [`https:\u002F\u002Fexample.com\u002Fuser\u002F${userId}`] })\n});\n",[731],{"type":32,"tag":91,"props":732,"children":733},{"__ignoreMap":16},[734,742,778,796,833,879],{"type":32,"tag":95,"props":735,"children":736},{"class":97,"line":98},[737],{"type":32,"tag":95,"props":738,"children":739},{"style":265},[740],{"type":37,"value":741},"\u002F\u002F На origin'е\n",{"type":32,"tag":95,"props":743,"children":744},{"class":97,"line":119},[745,750,754,758,763,768,773],{"type":32,"tag":95,"props":746,"children":747},{"style":102},[748],{"type":37,"value":749},"await",{"type":32,"tag":95,"props":751,"children":752},{"style":128},[753],{"type":37,"value":131},{"type":32,"tag":95,"props":755,"children":756},{"style":113},[757],{"type":37,"value":136},{"type":32,"tag":95,"props":759,"children":760},{"style":226},[761],{"type":37,"value":762},"`https:\u002F\u002Fapi.cloudflare.com\u002Fclient\u002Fv4\u002Fzones\u002F${",{"type":32,"tag":95,"props":764,"children":765},{"style":113},[766],{"type":37,"value":767},"zoneId",{"type":32,"tag":95,"props":769,"children":770},{"style":226},[771],{"type":37,"value":772},"}\u002Fpurge_cache`",{"type":32,"tag":95,"props":774,"children":775},{"style":113},[776],{"type":37,"value":777},", {\n",{"type":32,"tag":95,"props":779,"children":780},{"class":97,"line":160},[781,786,791],{"type":32,"tag":95,"props":782,"children":783},{"style":113},[784],{"type":37,"value":785},"  method: ",{"type":32,"tag":95,"props":787,"children":788},{"style":226},[789],{"type":37,"value":790},"'POST'",{"type":32,"tag":95,"props":792,"children":793},{"style":113},[794],{"type":37,"value":795},",\n",{"type":32,"tag":95,"props":797,"children":798},{"class":97,"line":195},[799,804,809,813,818,823,828],{"type":32,"tag":95,"props":800,"children":801},{"style":113},[802],{"type":37,"value":803},"  headers: { ",{"type":32,"tag":95,"props":805,"children":806},{"style":226},[807],{"type":37,"value":808},"'Authorization'",{"type":32,"tag":95,"props":810,"children":811},{"style":113},[812],{"type":37,"value":497},{"type":32,"tag":95,"props":814,"children":815},{"style":226},[816],{"type":37,"value":817},"`Bearer ${",{"type":32,"tag":95,"props":819,"children":820},{"style":113},[821],{"type":37,"value":822},"apiToken",{"type":32,"tag":95,"props":824,"children":825},{"style":226},[826],{"type":37,"value":827},"}`",{"type":32,"tag":95,"props":829,"children":830},{"style":113},[831],{"type":37,"value":832}," },\n",{"type":32,"tag":95,"props":834,"children":835},{"class":97,"line":252},[836,841,846,850,855,860,865,870,874],{"type":32,"tag":95,"props":837,"children":838},{"style":113},[839],{"type":37,"value":840},"  body: ",{"type":32,"tag":95,"props":842,"children":843},{"style":169},[844],{"type":37,"value":845},"JSON",{"type":32,"tag":95,"props":847,"children":848},{"style":113},[849],{"type":37,"value":71},{"type":32,"tag":95,"props":851,"children":852},{"style":128},[853],{"type":37,"value":854},"stringify",{"type":32,"tag":95,"props":856,"children":857},{"style":113},[858],{"type":37,"value":859},"({ files: [",{"type":32,"tag":95,"props":861,"children":862},{"style":226},[863],{"type":37,"value":864},"`https:\u002F\u002Fexample.com\u002Fuser\u002F${",{"type":32,"tag":95,"props":866,"children":867},{"style":113},[868],{"type":37,"value":869},"userId",{"type":32,"tag":95,"props":871,"children":872},{"style":226},[873],{"type":37,"value":827},{"type":32,"tag":95,"props":875,"children":876},{"style":113},[877],{"type":37,"value":878},"] })\n",{"type":32,"tag":95,"props":880,"children":881},{"class":97,"line":261},[882],{"type":32,"tag":95,"props":883,"children":884},{"style":113},[885],{"type":37,"value":886},"});\n",{"type":32,"tag":689,"props":888,"children":889},{"start":252},[890,895],{"type":32,"tag":693,"props":891,"children":892},{},[893],{"type":37,"value":894},"Edge-функция в следующем запросе читает новое значение из KV",{"type":32,"tag":693,"props":896,"children":897},{},[898],{"type":37,"value":899},"Клиентский JavaScript через 200ms выполняет мягкую перезагрузку",{"type":32,"tag":33,"props":901,"children":902},{},[903],{"type":37,"value":904},"Этот pattern ограничивает пропускную способность записей (rate limit KV: 1000\u002Fсек на аккаунт), но пропускная способность чтения не ограничена. Поэтому архитектура оптимизирована для read-heavy нагрузок. Действия пользователя редки (1–2 раза в минуту), просмотры страниц часты (100+ в секунду).",{"type":32,"tag":541,"props":906,"children":908},{"id":907},"стратегия-многоуровневого-кэширования",[909],{"type":37,"value":910},"Стратегия многоуровневого кэширования",{"type":32,"tag":33,"props":912,"children":913},{},[914],{"type":37,"value":915},"KV — не единственный уровень кэша. Полный стек:",{"type":32,"tag":84,"props":917,"children":919},{"code":918},"Кэш браузера (service worker)\n  ↓\nКэш CDN Edge (Cache API, 60s TTL)\n  ↓\nEdge KV (eventual, минуты)\n  ↓\nБаза данных Origin\n",[920],{"type":32,"tag":91,"props":921,"children":922},{"__ignoreMap":16},[923],{"type":37,"value":918},{"type":32,"tag":33,"props":925,"children":926},{},[927],{"type":37,"value":928},"Статические ресурсы (CSS, JS) на верхних уровнях, данные пользователя на нижних. Сам HTML находится в middle layer: edge-функция комбинирует KV и Cache API для рендеринга. Псевдокод:",{"type":32,"tag":84,"props":930,"children":932},{"code":931,"language":87,"meta":16,"className":88,"style":16},"const cacheKey = `html:${url}:${segment}`;\nlet html = await caches.default.match(cacheKey);\n\nif (!html) {\n  const userData = await KV.get(userId);\n  html = renderTemplate(userData);\n  await caches.default.put(cacheKey, html, { expirationTtl: 60 });\n}\n\nreturn html;\n",[933],{"type":32,"tag":91,"props":934,"children":935},{"__ignoreMap":16},[936,981,1018,1027,1050,1088,1110,1142,1150,1157],{"type":32,"tag":95,"props":937,"children":938},{"class":97,"line":98},[939,944,949,953,958,963,968,973,977],{"type":32,"tag":95,"props":940,"children":941},{"style":102},[942],{"type":37,"value":943},"const",{"type":32,"tag":95,"props":945,"children":946},{"style":169},[947],{"type":37,"value":948}," cacheKey",{"type":32,"tag":95,"props":950,"children":951},{"style":102},[952],{"type":37,"value":177},{"type":32,"tag":95,"props":954,"children":955},{"style":226},[956],{"type":37,"value":957}," `html:${",{"type":32,"tag":95,"props":959,"children":960},{"style":113},[961],{"type":37,"value":962},"url",{"type":32,"tag":95,"props":964,"children":965},{"style":226},[966],{"type":37,"value":967},"}:${",{"type":32,"tag":95,"props":969,"children":970},{"style":113},[971],{"type":37,"value":972},"segment",{"type":32,"tag":95,"props":974,"children":975},{"style":226},[976],{"type":37,"value":827},{"type":32,"tag":95,"props":978,"children":979},{"style":113},[980],{"type":37,"value":249},{"type":32,"tag":95,"props":982,"children":983},{"class":97,"line":119},[984,989,994,999,1003,1008,1013],{"type":32,"tag":95,"props":985,"children":986},{"style":102},[987],{"type":37,"value":988},"let",{"type":32,"tag":95,"props":990,"children":991},{"style":113},[992],{"type":37,"value":993}," html ",{"type":32,"tag":95,"props":995,"children":996},{"style":102},[997],{"type":37,"value":998},"=",{"type":32,"tag":95,"props":1000,"children":1001},{"style":102},[1002],{"type":37,"value":290},{"type":32,"tag":95,"props":1004,"children":1005},{"style":113},[1006],{"type":37,"value":1007}," caches.default.",{"type":32,"tag":95,"props":1009,"children":1010},{"style":128},[1011],{"type":37,"value":1012},"match",{"type":32,"tag":95,"props":1014,"children":1015},{"style":113},[1016],{"type":37,"value":1017},"(cacheKey);\n",{"type":32,"tag":95,"props":1019,"children":1020},{"class":97,"line":160},[1021],{"type":32,"tag":95,"props":1022,"children":1024},{"emptyLinePlaceholder":1023},true,[1025],{"type":37,"value":1026},"\n",{"type":32,"tag":95,"props":1028,"children":1029},{"class":97,"line":195},[1030,1035,1040,1045],{"type":32,"tag":95,"props":1031,"children":1032},{"style":102},[1033],{"type":37,"value":1034},"if",{"type":32,"tag":95,"props":1036,"children":1037},{"style":113},[1038],{"type":37,"value":1039}," (",{"type":32,"tag":95,"props":1041,"children":1042},{"style":102},[1043],{"type":37,"value":1044},"!",{"type":32,"tag":95,"props":1046,"children":1047},{"style":113},[1048],{"type":37,"value":1049},"html) {\n",{"type":32,"tag":95,"props":1051,"children":1052},{"class":97,"line":252},[1053,1058,1063,1067,1071,1076,1080,1084],{"type":32,"tag":95,"props":1054,"children":1055},{"style":102},[1056],{"type":37,"value":1057},"  const",{"type":32,"tag":95,"props":1059,"children":1060},{"style":169},[1061],{"type":37,"value":1062}," userData",{"type":32,"tag":95,"props":1064,"children":1065},{"style":102},[1066],{"type":37,"value":177},{"type":32,"tag":95,"props":1068,"children":1069},{"style":102},[1070],{"type":37,"value":290},{"type":32,"tag":95,"props":1072,"children":1073},{"style":169},[1074],{"type":37,"value":1075}," KV",{"type":32,"tag":95,"props":1077,"children":1078},{"style":113},[1079],{"type":37,"value":71},{"type":32,"tag":95,"props":1081,"children":1082},{"style":128},[1083],{"type":37,"value":219},{"type":32,"tag":95,"props":1085,"children":1086},{"style":113},[1087],{"type":37,"value":313},{"type":32,"tag":95,"props":1089,"children":1090},{"class":97,"line":261},[1091,1096,1100,1105],{"type":32,"tag":95,"props":1092,"children":1093},{"style":113},[1094],{"type":37,"value":1095},"  html ",{"type":32,"tag":95,"props":1097,"children":1098},{"style":102},[1099],{"type":37,"value":998},{"type":32,"tag":95,"props":1101,"children":1102},{"style":128},[1103],{"type":37,"value":1104}," renderTemplate",{"type":32,"tag":95,"props":1106,"children":1107},{"style":113},[1108],{"type":37,"value":1109},"(userData);\n",{"type":32,"tag":95,"props":1111,"children":1112},{"class":97,"line":271},[1113,1118,1122,1127,1132,1137],{"type":32,"tag":95,"props":1114,"children":1115},{"style":102},[1116],{"type":37,"value":1117},"  await",{"type":32,"tag":95,"props":1119,"children":1120},{"style":113},[1121],{"type":37,"value":1007},{"type":32,"tag":95,"props":1123,"children":1124},{"style":128},[1125],{"type":37,"value":1126},"put",{"type":32,"tag":95,"props":1128,"children":1129},{"style":113},[1130],{"type":37,"value":1131},"(cacheKey, html, { expirationTtl: ",{"type":32,"tag":95,"props":1133,"children":1134},{"style":169},[1135],{"type":37,"value":1136},"60",{"type":32,"tag":95,"props":1138,"children":1139},{"style":113},[1140],{"type":37,"value":1141}," });\n",{"type":32,"tag":95,"props":1143,"children":1144},{"class":97,"line":316},[1145],{"type":32,"tag":95,"props":1146,"children":1147},{"style":113},[1148],{"type":37,"value":1149},"}\n",{"type":32,"tag":95,"props":1151,"children":1152},{"class":97,"line":26},[1153],{"type":32,"tag":95,"props":1154,"children":1155},{"emptyLinePlaceholder":1023},[1156],{"type":37,"value":1026},{"type":32,"tag":95,"props":1158,"children":1159},{"class":97,"line":332},[1160,1165],{"type":32,"tag":95,"props":1161,"children":1162},{"style":102},[1163],{"type":37,"value":1164},"return",{"type":32,"tag":95,"props":1166,"children":1167},{"style":113},[1168],{"type":37,"value":1169}," html;\n",{"type":32,"tag":33,"props":1171,"children":1172},{},[1173],{"type":37,"value":1174},"Эта конструкция держит TTFB на 95-м перцентиле ниже 40ms, потому что большинство запросов обслуживаются из Cache API (5–8ms). Hit rate KV выше 98%, fallback на origin менее 2%.",{"type":32,"tag":40,"props":1176,"children":1178},{"id":1177},"scope-персонализации-и-trade-off-размера-бандла",[1179],{"type":37,"value":1180},"Scope персонализации и trade-off размера бандла",{"type":32,"tag":33,"props":1182,"children":1183},{},[1184],{"type":37,"value":1185},"Edge-функция имеет лимит размера бандла 1MB (Cloudflare). Нельзя рендерить тяжёлые React-компоненты. Два подхода:",{"type":32,"tag":33,"props":1187,"children":1188},{},[1189,1195],{"type":32,"tag":1190,"props":1191,"children":1192},"strong",{},[1193],{"type":37,"value":1194},"1. Минимальный templating:",{"type":37,"value":1196}," используй Handlebars или кастомную интерполяцию строк. Просто инжектируй переменные:",{"type":32,"tag":84,"props":1198,"children":1200},{"code":1199,"language":87,"meta":16,"className":88,"style":16},"const template = `\u003Cdiv class=\"product-card\">\n  \u003Ch3>{{name}}\u003C\u002Fh3>\n  \u003Cspan class=\"price {{priceClass}}\">{{price}}\u003C\u002Fspan>\n\u003C\u002Fdiv>`;\n\nfunction render(product, segment) {\n  return template\n    .replace('{{name}}', product.name)\n    .replace('{{price}}', segment === 'premium' ? product.premiumPrice : product.price)\n    .replace('{{priceClass}}', segment === 'premium' ? 'gold' : 'standard');\n}\n",[1201],{"type":32,"tag":91,"props":1202,"children":1203},{"__ignoreMap":16},[1204,1225,1233,1241,1253,1260,1294,1307,1334,1387,1443],{"type":32,"tag":95,"props":1205,"children":1206},{"class":97,"line":98},[1207,1211,1216,1220],{"type":32,"tag":95,"props":1208,"children":1209},{"style":102},[1210],{"type":37,"value":943},{"type":32,"tag":95,"props":1212,"children":1213},{"style":169},[1214],{"type":37,"value":1215}," template",{"type":32,"tag":95,"props":1217,"children":1218},{"style":102},[1219],{"type":37,"value":177},{"type":32,"tag":95,"props":1221,"children":1222},{"style":226},[1223],{"type":37,"value":1224}," `\u003Cdiv class=\"product-card\">\n",{"type":32,"tag":95,"props":1226,"children":1227},{"class":97,"line":119},[1228],{"type":32,"tag":95,"props":1229,"children":1230},{"style":226},[1231],{"type":37,"value":1232},"  \u003Ch3>{{name}}\u003C\u002Fh3>\n",{"type":32,"tag":95,"props":1234,"children":1235},{"class":97,"line":160},[1236],{"type":32,"tag":95,"props":1237,"children":1238},{"style":226},[1239],{"type":37,"value":1240},"  \u003Cspan class=\"price {{priceClass}}\">{{price}}\u003C\u002Fspan>\n",{"type":32,"tag":95,"props":1242,"children":1243},{"class":97,"line":195},[1244,1249],{"type":32,"tag":95,"props":1245,"children":1246},{"style":226},[1247],{"type":37,"value":1248},"\u003C\u002Fdiv>`",{"type":32,"tag":95,"props":1250,"children":1251},{"style":113},[1252],{"type":37,"value":249},{"type":32,"tag":95,"props":1254,"children":1255},{"class":97,"line":252},[1256],{"type":32,"tag":95,"props":1257,"children":1258},{"emptyLinePlaceholder":1023},[1259],{"type":37,"value":1026},{"type":32,"tag":95,"props":1261,"children":1262},{"class":97,"line":261},[1263,1268,1273,1277,1282,1286,1290],{"type":32,"tag":95,"props":1264,"children":1265},{"style":102},[1266],{"type":37,"value":1267},"function",{"type":32,"tag":95,"props":1269,"children":1270},{"style":128},[1271],{"type":37,"value":1272}," render",{"type":32,"tag":95,"props":1274,"children":1275},{"style":113},[1276],{"type":37,"value":136},{"type":32,"tag":95,"props":1278,"children":1279},{"style":139},[1280],{"type":37,"value":1281},"product",{"type":32,"tag":95,"props":1283,"children":1284},{"style":113},[1285],{"type":37,"value":147},{"type":32,"tag":95,"props":1287,"children":1288},{"style":139},[1289],{"type":37,"value":972},{"type":32,"tag":95,"props":1291,"children":1292},{"style":113},[1293],{"type":37,"value":157},{"type":32,"tag":95,"props":1295,"children":1296},{"class":97,"line":271},[1297,1302],{"type":32,"tag":95,"props":1298,"children":1299},{"style":102},[1300],{"type":37,"value":1301},"  return",{"type":32,"tag":95,"props":1303,"children":1304},{"style":113},[1305],{"type":37,"value":1306}," template\n",{"type":32,"tag":95,"props":1308,"children":1309},{"class":97,"line":316},[1310,1315,1320,1324,1329],{"type":32,"tag":95,"props":1311,"children":1312},{"style":113},[1313],{"type":37,"value":1314},"    .",{"type":32,"tag":95,"props":1316,"children":1317},{"style":128},[1318],{"type":37,"value":1319},"replace",{"type":32,"tag":95,"props":1321,"children":1322},{"style":113},[1323],{"type":37,"value":136},{"type":32,"tag":95,"props":1325,"children":1326},{"style":226},[1327],{"type":37,"value":1328},"'{{name}}'",{"type":32,"tag":95,"props":1330,"children":1331},{"style":113},[1332],{"type":37,"value":1333},", product.name)\n",{"type":32,"tag":95,"props":1335,"children":1336},{"class":97,"line":26},[1337,1341,1345,1349,1354,1359,1363,1367,1372,1377,1382],{"type":32,"tag":95,"props":1338,"children":1339},{"style":113},[1340],{"type":37,"value":1314},{"type":32,"tag":95,"props":1342,"children":1343},{"style":128},[1344],{"type":37,"value":1319},{"type":32,"tag":95,"props":1346,"children":1347},{"style":113},[1348],{"type":37,"value":136},{"type":32,"tag":95,"props":1350,"children":1351},{"style":226},[1352],{"type":37,"value":1353},"'{{price}}'",{"type":32,"tag":95,"props":1355,"children":1356},{"style":113},[1357],{"type":37,"value":1358},", segment ",{"type":32,"tag":95,"props":1360,"children":1361},{"style":102},[1362],{"type":37,"value":356},{"type":32,"tag":95,"props":1364,"children":1365},{"style":226},[1366],{"type":37,"value":361},{"type":32,"tag":95,"props":1368,"children":1369},{"style":102},[1370],{"type":37,"value":1371}," ?",{"type":32,"tag":95,"props":1373,"children":1374},{"style":113},[1375],{"type":37,"value":1376}," product.premiumPrice ",{"type":32,"tag":95,"props":1378,"children":1379},{"style":102},[1380],{"type":37,"value":1381},":",{"type":32,"tag":95,"props":1383,"children":1384},{"style":113},[1385],{"type":37,"value":1386}," product.price)\n",{"type":32,"tag":95,"props":1388,"children":1389},{"class":97,"line":332},[1390,1394,1398,1402,1407,1411,1415,1419,1423,1428,1433,1438],{"type":32,"tag":95,"props":1391,"children":1392},{"style":113},[1393],{"type":37,"value":1314},{"type":32,"tag":95,"props":1395,"children":1396},{"style":128},[1397],{"type":37,"value":1319},{"type":32,"tag":95,"props":1399,"children":1400},{"style":113},[1401],{"type":37,"value":136},{"type":32,"tag":95,"props":1403,"children":1404},{"style":226},[1405],{"type":37,"value":1406},"'{{priceClass}}'",{"type":32,"tag":95,"props":1408,"children":1409},{"style":113},[1410],{"type":37,"value":1358},{"type":32,"tag":95,"props":1412,"children":1413},{"style":102},[1414],{"type":37,"value":356},{"type":32,"tag":95,"props":1416,"children":1417},{"style":226},[1418],{"type":37,"value":361},{"type":32,"tag":95,"props":1420,"children":1421},{"style":102},[1422],{"type":37,"value":1371},{"type":32,"tag":95,"props":1424,"children":1425},{"style":226},[1426],{"type":37,"value":1427}," 'gold'",{"type":32,"tag":95,"props":1429,"children":1430},{"style":102},[1431],{"type":37,"value":1432}," :",{"type":32,"tag":95,"props":1434,"children":1435},{"style":226},[1436],{"type":37,"value":1437}," 'standard'",{"type":32,"tag":95,"props":1439,"children":1440},{"style":113},[1441],{"type":37,"value":1442},");\n",{"type":32,"tag":95,"props":1444,"children":1445},{"class":97,"line":369},[1446],{"type":32,"tag":95,"props":1447,"children":1448},{"style":113},[1449],{"type":37,"value":1149},{"type":32,"tag":33,"props":1451,"children":1452},{},[1453],{"type":37,"value":1454},"Размер бандла: 2KB. Время рендеринга: 0.3ms.",{"type":32,"tag":33,"props":1456,"children":1457},{},[1458,1463],{"type":32,"tag":1190,"props":1459,"children":1460},{},[1461],{"type":37,"value":1462},"2. Partial hydration:",{"type":37,"value":1464}," рендерируй skeleton HTML на edge, гидрируй React-island'ы на клиенте. Edge-функция:",{"type":32,"tag":84,"props":1466,"children":1468},{"code":1467,"language":87,"meta":16,"className":88,"style":16},"export default async function(request) {\n  const products = await fetchProducts();\n  return `\n    \u003Cdiv id=\"product-list\" data-products='${JSON.stringify(products)}'>\n      ${products.map(p => `\u003Cdiv class=\"skeleton\">\u003C\u002Fdiv>`).join('')}\n    \u003C\u002Fdiv>\n    \u003Cscript type=\"module\" src=\"\u002Fhydrate.js\">\u003C\u002Fscript>\n  `;\n}\n",[1469],{"type":32,"tag":91,"props":1470,"children":1471},{"__ignoreMap":16},[1472,1505,1533,1545,1584,1650,1658,1666,1678],{"type":32,"tag":95,"props":1473,"children":1474},{"class":97,"line":98},[1475,1479,1483,1488,1493,1497,1501],{"type":32,"tag":95,"props":1476,"children":1477},{"style":102},[1478],{"type":37,"value":105},{"type":32,"tag":95,"props":1480,"children":1481},{"style":102},[1482],{"type":37,"value":110},{"type":32,"tag":95,"props":1484,"children":1485},{"style":102},[1486],{"type":37,"value":1487}," async",{"type":32,"tag":95,"props":1489,"children":1490},{"style":102},[1491],{"type":37,"value":1492}," function",{"type":32,"tag":95,"props":1494,"children":1495},{"style":113},[1496],{"type":37,"value":136},{"type":32,"tag":95,"props":1498,"children":1499},{"style":139},[1500],{"type":37,"value":142},{"type":32,"tag":95,"props":1502,"children":1503},{"style":113},[1504],{"type":37,"value":157},{"type":32,"tag":95,"props":1506,"children":1507},{"class":97,"line":119},[1508,1512,1516,1520,1524,1529],{"type":32,"tag":95,"props":1509,"children":1510},{"style":102},[1511],{"type":37,"value":1057},{"type":32,"tag":95,"props":1513,"children":1514},{"style":169},[1515],{"type":37,"value":342},{"type":32,"tag":95,"props":1517,"children":1518},{"style":102},[1519],{"type":37,"value":177},{"type":32,"tag":95,"props":1521,"children":1522},{"style":102},[1523],{"type":37,"value":290},{"type":32,"tag":95,"props":1525,"children":1526},{"style":128},[1527],{"type":37,"value":1528}," fetchProducts",{"type":32,"tag":95,"props":1530,"children":1531},{"style":113},[1532],{"type":37,"value":412},{"type":32,"tag":95,"props":1534,"children":1535},{"class":97,"line":160},[1536,1540],{"type":32,"tag":95,"props":1537,"children":1538},{"style":102},[1539],{"type":37,"value":1301},{"type":32,"tag":95,"props":1541,"children":1542},{"style":226},[1543],{"type":37,"value":1544}," `\n",{"type":32,"tag":95,"props":1546,"children":1547},{"class":97,"line":195},[1548,1553,1557,1561,1565,1569,1574,1579],{"type":32,"tag":95,"props":1549,"children":1550},{"style":226},[1551],{"type":37,"value":1552},"    \u003Cdiv id=\"product-list\" data-products='${",{"type":32,"tag":95,"props":1554,"children":1555},{"style":169},[1556],{"type":37,"value":845},{"type":32,"tag":95,"props":1558,"children":1559},{"style":226},[1560],{"type":37,"value":71},{"type":32,"tag":95,"props":1562,"children":1563},{"style":128},[1564],{"type":37,"value":854},{"type":32,"tag":95,"props":1566,"children":1567},{"style":226},[1568],{"type":37,"value":136},{"type":32,"tag":95,"props":1570,"children":1571},{"style":113},[1572],{"type":37,"value":1573},"products",{"type":32,"tag":95,"props":1575,"children":1576},{"style":226},[1577],{"type":37,"value":1578},")",{"type":32,"tag":95,"props":1580,"children":1581},{"style":226},[1582],{"type":37,"value":1583},"}'>\n",{"type":32,"tag":95,"props":1585,"children":1586},{"class":97,"line":252},[1587,1592,1596,1600,1605,1609,1613,1618,1623,1628,1633,1637,1642,1646],{"type":32,"tag":95,"props":1588,"children":1589},{"style":226},[1590],{"type":37,"value":1591},"      ${",{"type":32,"tag":95,"props":1593,"children":1594},{"style":113},[1595],{"type":37,"value":1573},{"type":32,"tag":95,"props":1597,"children":1598},{"style":226},[1599],{"type":37,"value":71},{"type":32,"tag":95,"props":1601,"children":1602},{"style":128},[1603],{"type":37,"value":1604},"map",{"type":32,"tag":95,"props":1606,"children":1607},{"style":226},[1608],{"type":37,"value":136},{"type":32,"tag":95,"props":1610,"children":1611},{"style":169},[1612],{"type":37,"value":33},{"type":32,"tag":95,"props":1614,"children":1615},{"style":102},[1616],{"type":37,"value":1617}," =>",{"type":32,"tag":95,"props":1619,"children":1620},{"style":226},[1621],{"type":37,"value":1622}," `\u003Cdiv class=\"skeleton\">\u003C\u002Fdiv>`",{"type":32,"tag":95,"props":1624,"children":1625},{"style":226},[1626],{"type":37,"value":1627},").",{"type":32,"tag":95,"props":1629,"children":1630},{"style":128},[1631],{"type":37,"value":1632},"join",{"type":32,"tag":95,"props":1634,"children":1635},{"style":226},[1636],{"type":37,"value":136},{"type":32,"tag":95,"props":1638,"children":1639},{"style":226},[1640],{"type":37,"value":1641},"''",{"type":32,"tag":95,"props":1643,"children":1644},{"style":226},[1645],{"type":37,"value":1578},{"type":32,"tag":95,"props":1647,"children":1648},{"style":226},[1649],{"type":37,"value":1149},{"type":32,"tag":95,"props":1651,"children":1652},{"class":97,"line":261},[1653],{"type":32,"tag":95,"props":1654,"children":1655},{"style":226},[1656],{"type":37,"value":1657},"    \u003C\u002Fdiv>\n",{"type":32,"tag":95,"props":1659,"children":1660},{"class":97,"line":271},[1661],{"type":32,"tag":95,"props":1662,"children":1663},{"style":226},[1664],{"type":37,"value":1665},"    \u003Cscript type=\"module\" src=\"\u002Fhydrate.js\">\u003C\u002Fscript>\n",{"type":32,"tag":95,"props":1667,"children":1668},{"class":97,"line":316},[1669,1674],{"type":32,"tag":95,"props":1670,"children":1671},{"style":226},[1672],{"type":37,"value":1673},"  `",{"type":32,"tag":95,"props":1675,"children":1676},{"style":113},[1677],{"type":37,"value":249},{"type":32,"tag":95,"props":1679,"children":1680},{"class":97,"line":26},[1681],{"type":32,"tag":95,"props":1682,"children":1683},{"style":113},[1684],{"type":37,"value":1149},{"type":32,"tag":33,"props":1686,"children":1687},{},[1688,1690,1696],{"type":37,"value":1689},"Клиентский код ",{"type":32,"tag":91,"props":1691,"children":1693},{"className":1692},[],[1694],{"type":37,"value":1695},"hydrate.js",{"type":37,"value":1697}," (10KB):",{"type":32,"tag":84,"props":1699,"children":1701},{"code":1700,"language":87,"meta":16,"className":88,"style":16},"import { h, render } from 'preact';\nconst data = JSON.parse(document.getElementById('product-list').dataset.products);\nrender(\u003CProductList products={data} \u002F>, document.getElementById('product-list'));\n",[1702],{"type":32,"tag":91,"props":1703,"children":1704},{"__ignoreMap":16},[1705,1732,1786],{"type":32,"tag":95,"props":1706,"children":1707},{"class":97,"line":98},[1708,1713,1718,1723,1728],{"type":32,"tag":95,"props":1709,"children":1710},{"style":102},[1711],{"type":37,"value":1712},"import",{"type":32,"tag":95,"props":1714,"children":1715},{"style":113},[1716],{"type":37,"value":1717}," { h, render } ",{"type":32,"tag":95,"props":1719,"children":1720},{"style":102},[1721],{"type":37,"value":1722},"from",{"type":32,"tag":95,"props":1724,"children":1725},{"style":226},[1726],{"type":37,"value":1727}," 'preact'",{"type":32,"tag":95,"props":1729,"children":1730},{"style":113},[1731],{"type":37,"value":249},{"type":32,"tag":95,"props":1733,"children":1734},{"class":97,"line":119},[1735,1739,1744,1748,1753,1757,1762,1767,1772,1776,1781],{"type":32,"tag":95,"props":1736,"children":1737},{"style":102},[1738],{"type":37,"value":943},{"type":32,"tag":95,"props":1740,"children":1741},{"style":169},[1742],{"type":37,"value":1743}," data",{"type":32,"tag":95,"props":1745,"children":1746},{"style":102},[1747],{"type":37,"value":177},{"type":32,"tag":95,"props":1749,"children":1750},{"style":169},[1751],{"type":37,"value":1752}," JSON",{"type":32,"tag":95,"props":1754,"children":1755},{"style":113},[1756],{"type":37,"value":71},{"type":32,"tag":95,"props":1758,"children":1759},{"style":128},[1760],{"type":37,"value":1761},"parse",{"type":32,"tag":95,"props":1763,"children":1764},{"style":113},[1765],{"type":37,"value":1766},"(document.",{"type":32,"tag":95,"props":1768,"children":1769},{"style":128},[1770],{"type":37,"value":1771},"getElementById",{"type":32,"tag":95,"props":1773,"children":1774},{"style":113},[1775],{"type":37,"value":136},{"type":32,"tag":95,"props":1777,"children":1778},{"style":226},[1779],{"type":37,"value":1780},"'product-list'",{"type":32,"tag":95,"props":1782,"children":1783},{"style":113},[1784],{"type":37,"value":1785},").dataset.products);\n",{"type":32,"tag":95,"props":1787,"children":1788},{"class":97,"line":160},[1789,1794,1799,1804,1808,1812,1817,1821,1825,1829],{"type":32,"tag":95,"props":1790,"children":1791},{"style":128},[1792],{"type":37,"value":1793},"render",{"type":32,"tag":95,"props":1795,"children":1796},{"style":113},[1797],{"type":37,"value":1798},"(\u003C",{"type":32,"tag":95,"props":1800,"children":1801},{"style":169},[1802],{"type":37,"value":1803},"ProductList",{"type":32,"tag":95,"props":1805,"children":1806},{"style":128},[1807],{"type":37,"value":342},{"type":32,"tag":95,"props":1809,"children":1810},{"style":102},[1811],{"type":37,"value":998},{"type":32,"tag":95,"props":1813,"children":1814},{"style":113},[1815],{"type":37,"value":1816},"{data} \u002F>, document.",{"type":32,"tag":95,"props":1818,"children":1819},{"style":128},[1820],{"type":37,"value":1771},{"type":32,"tag":95,"props":1822,"children":1823},{"style":113},[1824],{"type":37,"value":136},{"type":32,"tag":95,"props":1826,"children":1827},{"style":226},[1828],{"type":37,"value":1780},{"type":32,"tag":95,"props":1830,"children":1831},{"style":113},[1832],{"type":37,"value":1833},"));\n",{"type":32,"tag":33,"props":1835,"children":1836},{},[1837],{"type":37,"value":1838},"Этот паттерн держит edge SSR латентность низкой (40ms), интерактивность приходит с клиента (FCP + 150ms). Trade-off: INP может вырасти (время парсинга JavaScript). Требуется мониторинг.",{"type":32,"tag":40,"props":1840,"children":1842},{"id":1841},"real-user-monitoring-и-alerting",[1843],{"type":37,"value":1844},"Real User Monitoring и alerting",{"type":32,"tag":33,"props":1846,"children":1847},{},[1848],{"type":37,"value":1849},"Без RUM невозможно оптимизировать edge-латентность. Cloudflare Analytics добавляет Server-Timing header в каждый запрос:",{"type":32,"tag":84,"props":1851,"children":1853},{"code":1852},"Server-Timing: cf-edge;dur=12, cf-kv;dur=8, cf-render;dur=18\n",[1854],{"type":32,"tag":91,"props":1855,"children":1856},{"__ignoreMap":16},[1857],{"type":37,"value":1852},{"type":32,"tag":33,"props":1859,"children":1860},{},[1861],{"type":37,"value":1862},"Собирай это на клиенте через PerformanceObserver:",{"type":32,"tag":84,"props":1864,"children":1866},{"code":1865,"language":87,"meta":16,"className":88,"style":16},"new PerformanceObserver((list) => {\n  for (const entry of list.getEntries()) {\n    if (entry.entryType === 'navigation') {\n      const ttfb = entry.responseStart - entry.requestStart;\n      fetch('\u002Fanalytics', { \n        method: 'POST', \n        body: JSON.stringify({ ttfb, url: entry.name }) \n      });\n    }\n  }\n}).observe({ entryTypes: ['navigation'] });\n",[1867],{"type":32,"tag":91,"props":1868,"children":1869},{"__ignoreMap":16},[1870,1906,1947,1973,2005,2027,2044,2069,2077,2085,2092],{"type":32,"tag":95,"props":1871,"children":1872},{"class":97,"line":98},[1873,1878,1883,1888,1893,1897,1902],{"type":32,"tag":95,"props":1874,"children":1875},{"style":102},[1876],{"type":37,"value":1877},"new",{"type":32,"tag":95,"props":1879,"children":1880},{"style":128},[1881],{"type":37,"value":1882}," PerformanceObserver",{"type":32,"tag":95,"props":1884,"children":1885},{"style":113},[1886],{"type":37,"value":1887},"((",{"type":32,"tag":95,"props":1889,"children":1890},{"style":139},[1891],{"type":37,"value":1892},"list",{"type":32,"tag":95,"props":1894,"children":1895},{"style":113},[1896],{"type":37,"value":234},{"type":32,"tag":95,"props":1898,"children":1899},{"style":102},[1900],{"type":37,"value":1901},"=>",{"type":32,"tag":95,"props":1903,"children":1904},{"style":113},[1905],{"type":37,"value":116},{"type":32,"tag":95,"props":1907,"children":1908},{"class":97,"line":119},[1909,1914,1918,1922,1927,1932,1937,1942],{"type":32,"tag":95,"props":1910,"children":1911},{"style":102},[1912],{"type":37,"value":1913},"  for",{"type":32,"tag":95,"props":1915,"children":1916},{"style":113},[1917],{"type":37,"value":1039},{"type":32,"tag":95,"props":1919,"children":1920},{"style":102},[1921],{"type":37,"value":943},{"type":32,"tag":95,"props":1923,"children":1924},{"style":169},[1925],{"type":37,"value":1926}," entry",{"type":32,"tag":95,"props":1928,"children":1929},{"style":102},[1930],{"type":37,"value":1931}," of",{"type":32,"tag":95,"props":1933,"children":1934},{"style":113},[1935],{"type":37,"value":1936}," list.",{"type":32,"tag":95,"props":1938,"children":1939},{"style":128},[1940],{"type":37,"value":1941},"getEntries",{"type":32,"tag":95,"props":1943,"children":1944},{"style":113},[1945],{"type":37,"value":1946},"()) {\n",{"type":32,"tag":95,"props":1948,"children":1949},{"class":97,"line":160},[1950,1955,1960,1964,1969],{"type":32,"tag":95,"props":1951,"children":1952},{"style":102},[1953],{"type":37,"value":1954},"    if",{"type":32,"tag":95,"props":1956,"children":1957},{"style":113},[1958],{"type":37,"value":1959}," (entry.entryType ",{"type":32,"tag":95,"props":1961,"children":1962},{"style":102},[1963],{"type":37,"value":356},{"type":32,"tag":95,"props":1965,"children":1966},{"style":226},[1967],{"type":37,"value":1968}," 'navigation'",{"type":32,"tag":95,"props":1970,"children":1971},{"style":113},[1972],{"type":37,"value":157},{"type":32,"tag":95,"props":1974,"children":1975},{"class":97,"line":195},[1976,1981,1986,1990,1995,2000],{"type":32,"tag":95,"props":1977,"children":1978},{"style":102},[1979],{"type":37,"value":1980},"      const",{"type":32,"tag":95,"props":1982,"children":1983},{"style":169},[1984],{"type":37,"value":1985}," ttfb",{"type":32,"tag":95,"props":1987,"children":1988},{"style":102},[1989],{"type":37,"value":177},{"type":32,"tag":95,"props":1991,"children":1992},{"style":113},[1993],{"type":37,"value":1994}," entry.responseStart ",{"type":32,"tag":95,"props":1996,"children":1997},{"style":102},[1998],{"type":37,"value":1999},"-",{"type":32,"tag":95,"props":2001,"children":2002},{"style":113},[2003],{"type":37,"value":2004}," entry.requestStart;\n",{"type":32,"tag":95,"props":2006,"children":2007},{"class":97,"line":252},[2008,2013,2017,2022],{"type":32,"tag":95,"props":2009,"children":2010},{"style":128},[2011],{"type":37,"value":2012},"      fetch",{"type":32,"tag":95,"props":2014,"children":2015},{"style":113},[2016],{"type":37,"value":136},{"type":32,"tag":95,"props":2018,"children":2019},{"style":226},[2020],{"type":37,"value":2021},"'\u002Fanalytics'",{"type":32,"tag":95,"props":2023,"children":2024},{"style":113},[2025],{"type":37,"value":2026},", { \n",{"type":32,"tag":95,"props":2028,"children":2029},{"class":97,"line":261},[2030,2035,2039],{"type":32,"tag":95,"props":2031,"children":2032},{"style":113},[2033],{"type":37,"value":2034},"        method: ",{"type":32,"tag":95,"props":2036,"children":2037},{"style":226},[2038],{"type":37,"value":790},{"type":32,"tag":95,"props":2040,"children":2041},{"style":113},[2042],{"type":37,"value":2043},", \n",{"type":32,"tag":95,"props":2045,"children":2046},{"class":97,"line":271},[2047,2052,2056,2060,2064],{"type":32,"tag":95,"props":2048,"children":2049},{"style":113},[2050],{"type":37,"value":2051},"        body: ",{"type":32,"tag":95,"props":2053,"children":2054},{"style":169},[2055],{"type":37,"value":845},{"type":32,"tag":95,"props":2057,"children":2058},{"style":113},[2059],{"type":37,"value":71},{"type":32,"tag":95,"props":2061,"children":2062},{"style":128},[2063],{"type":37,"value":854},{"type":32,"tag":95,"props":2065,"children":2066},{"style":113},[2067],{"type":37,"value":2068},"({ ttfb, url: entry.name }) \n",{"type":32,"tag":95,"props":2070,"children":2071},{"class":97,"line":316},[2072],{"type":32,"tag":95,"props":2073,"children":2074},{"style":113},[2075],{"type":37,"value":2076},"      });\n",{"type":32,"tag":95,"props":2078,"children":2079},{"class":97,"line":26},[2080],{"type":32,"tag":95,"props":2081,"children":2082},{"style":113},[2083],{"type":37,"value":2084},"    }\n",{"type":32,"tag":95,"props":2086,"children":2087},{"class":97,"line":332},[2088],{"type":32,"tag":95,"props":2089,"children":2090},{"style":113},[2091],{"type":37,"value":525},{"type":32,"tag":95,"props":2093,"children":2094},{"class":97,"line":369},[2095,2100,2105,2110,2115],{"type":32,"tag":95,"props":2096,"children":2097},{"style":113},[2098],{"type":37,"value":2099},"}).",{"type":32,"tag":95,"props":2101,"children":2102},{"style":128},[2103],{"type":37,"value":2104},"observe",{"type":32,"tag":95,"props":2106,"children":2107},{"style":113},[2108],{"type":37,"value":2109},"({ entryTypes: [",{"type":32,"tag":95,"props":2111,"children":2112},{"style":226},[2113],{"type":37,"value":2114},"'navigation'",{"type":32,"tag":95,"props":2116,"children":2117},{"style":113},[2118],{"type":37,"value":2119},"] });\n",{"type":32,"tag":33,"props":2121,"children":2122},{},[2123],{"type":37,"value":2124},"Целевые метрики:",{"type":32,"tag":2126,"props":2127,"children":2128},"ul",{},[2129,2134,2139,2144],{"type":32,"tag":693,"props":2130,"children":2131},{},[2132],{"type":37,"value":2133},"p50 TTFB \u003C 30ms",{"type":32,"tag":693,"props":2135,"children":2136},{},[2137],{"type":37,"value":2138},"p95 TTFB \u003C 60ms",{"type":32,"tag":693,"props":2140,"children":2141},{},[2142],{"type":37,"value":2143},"p99 TTFB \u003C 100ms",{"type":32,"tag":693,"props":2145,"children":2146},{},[2147],{"type":37,"value":2148},"Error rate на edge \u003C 0.1%",{"type":32,"tag":33,"props":2150,"children":2151},{},[2152,2154,2160],{"type":37,"value":2153},"Запросы, превышающие 60ms, логируй с trace ID от Cloudflare, дебагируй через ",{"type":32,"tag":91,"props":2155,"children":2157},{"className":2156},[],[2158],{"type":37,"value":2159},"wrangler tail",{"type":37,"value":2161},". Чаще всего причина — timeout KV или fallback на origin.",{"type":32,"tag":40,"props":2163,"children":2165},{"id":2164},"чек-лист-для-production-deploymentа",[2166],{"type":37,"value":2167},"Чек-лист для production-deployment'а",{"type":32,"tag":33,"props":2169,"children":2170},{},[2171],{"type":37,"value":2172},"Перед запуском Edge SSR в production:",{"type":32,"tag":689,"props":2174,"children":2175},{},[2176,2186,2196,2206,2216],{"type":32,"tag":693,"props":2177,"children":2178},{},[2179,2184],{"type":32,"tag":1190,"props":2180,"children":2181},{},[2182],{"type":37,"value":2183},"Rate limiting:",{"type":37,"value":2185}," throttle KV write (максимум 1 запись в секунду на пользователя)",{"type":32,"tag":693,"props":2187,"children":2188},{},[2189,2194],{"type":32,"tag":1190,"props":2190,"children":2191},{},[2192],{"type":37,"value":2193},"Fallback chain:",{"type":37,"value":2195}," если KV timeout (>50ms), fallback на origin; если origin timeout, отправь static HTML",{"type":32,"tag":693,"props":2197,"children":2198},{},[2199,2204],{"type":32,"tag":1190,"props":2200,"children":2201},{},[2202],{"type":37,"value":2203},"Feature flag:",{"type":37,"value":2205}," раскатывай edge-персонализацию постепенно (10% → 50% → 100% трафика)",{"type":32,"tag":693,"props":2207,"children":2208},{},[2209,2214],{"type":32,"tag":1190,"props":2210,"children":2211},{},[2212],{"type":37,"value":2213},"Cost monitoring:",{"type":37,"value":2215}," Cloudflare Workers даёт 100K запросов\u002Fдень бесплатно, далее $0.50 за миллион. KV read бесплатен без лимита, write стоит $0.50 за миллион.",{"type":32,"tag":693,"props":2217,"children":2218},{},[2219,2224],{"type":32,"tag":1190,"props":2220,"children":2221},{},[2222],{"type":37,"value":2223},"Security:",{"type":37,"value":2225}," хэшируй user ID, не храни PII в ключах KV, добавь bot detection для защиты от rate limit bypass",{"type":32,"tag":33,"props":2227,"children":2228},{},[2229],{"type":37,"value":2230},"Расчёт стоимости: 1M посещений в день, 30% персонализированных запросов = 300K edge invocation\u002Fдень = $0.15\u002Fдень = $4.50\u002Fмесяц. Альтернатива (origin SSR): инстанс с 2 vCPU стоит $50\u002Fмесяц. Экономия: 91%.",{"type":32,"tag":33,"props":2232,"children":2233},{},[2234],{"type":37,"value":2235},"После настройки Edge SSR incremental cost стремится к нулю. Добавить новое правило персонализации — просто записать новый ключ в KV. Создать новый сегмент — добавить один if-блок в edge-функцию. Масштабирование нелинейное — 10M запросов в день обслуживаются с той же 40ms латентностью. Вот почему в стратегии роста важно думать edge-first с самого начала.",{"type":32,"tag":2237,"props":2238,"children":2239},"style",{},[2240],{"type":37,"value":2241},"html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}",{"title":16,"searchDepth":160,"depth":160,"links":2243},[2244,2245,2248,2251,2252,2253],{"id":42,"depth":119,"text":45},{"id":74,"depth":119,"text":77,"children":2246},[2247],{"id":543,"depth":160,"text":546},{"id":674,"depth":119,"text":677,"children":2249},[2250],{"id":907,"depth":160,"text":910},{"id":1177,"depth":119,"text":1180},{"id":1841,"depth":119,"text":1844},{"id":2164,"depth":119,"text":2167},"markdown","content:ru:tech:edge-ssr-snizit-personalizacija-latenciju-40ms.md","content","ru\u002Ftech\u002Fedge-ssr-snizit-personalizacija-latenciju-40ms.md","ru\u002Ftech\u002Fedge-ssr-snizit-personalizacija-latenciju-40ms","md",1778709808846]