[{"data":1,"prerenderedAt":2904},["ShallowReactive",2],{"article-alternates":3,"article-\u002Fes\u002Ftech\u002Fedge-ssr-40ms-latency":13},{"i18nKey":4,"paths":5},"tech-003-2026-07",{"de":6,"en":7,"es":8,"fr":9,"it":10,"ru":11,"tr":12},"\u002Fde\u002Ftech\u002Fedge-ssr-personalisierung-40ms-latenz","\u002Fen\u002Ftech\u002Fedge-ssr-personalization-latency-40ms","\u002Fes\u002Ftech\u002Freducir-latencia-personalizacion-edge-ssr-40ms","\u002Ffr\u002Ftech\u002Fedge-ssr-personnalisation-latence-40ms","\u002Fit\u002Ftech\u002Fedge-ssr-ridurre-latenza-personalizzazione-40ms","\u002Fru\u002Ftech\u002Freducir-latencia-personalizacion-40ms-edge-ssr","\u002Ftr\u002Ftech\u002Fedge-ssr-ile-personalizasyon-latencysini-40msye-dusurmek",{"_path":14,"_dir":15,"_draft":16,"_partial":16,"_locale":17,"title":18,"description":19,"publishedAt":20,"modifiedAt":20,"category":15,"i18nKey":4,"tags":21,"readingTime":27,"author":28,"body":29,"_type":2898,"_id":2899,"_source":2900,"_file":2901,"_stem":2902,"_extension":2903},"\u002Fes\u002Ftech\u002Fedge-ssr-40ms-latency","tech",false,"","Reducir la Latencia de Personalización con Edge SSR a 40ms","Arquitectura en producción con Cloudflare Workers y Vercel Edge usando KV store para disminuir SSR personalizado de 200ms a 40ms.","2026-07-28",[22,23,24,25,26],"edge-ssr","cloudflare-workers","vercel-edge","kv-store","rendimiento-web",9,"Roibase",{"type":30,"children":31,"toc":2888},"root",[32,40,47,52,57,62,68,73,921,930,962,967,974,979,1471,1476,1482,1526,1534,1547,1560,1594,1604,1610,1615,1625,1945,1955,2267,2272,2278,2294,2299,2767,2772,2782,2788,2793,2801,2867,2877,2882],{"type":33,"tag":34,"props":35,"children":36},"element","p",{},[37],{"type":38,"value":39},"text","En 2026, la personalización SSR sigue siendo costosa: transportar contexto de usuario al servidor origen, consultar base de datos, renderizar, devolver por CDN. Latencia promedio de 200-300ms. Edge SSR elimina este ciclo — obtén datos del KV store en el punto más cercano al usuario, renderiza, devuelve. ¿Qué arquitectura hay detrás de una latencia que cae a 40ms en producción?",{"type":33,"tag":41,"props":42,"children":44},"h2",{"id":43},"la-economía-que-edge-ssr-desbloquea",[45],{"type":38,"value":46},"La Economía que Edge SSR Desbloquea",{"type":33,"tag":34,"props":48,"children":49},{},[50],{"type":38,"value":51},"Con SSR basado en origen, cada request sigue el mismo camino: edge CDN → servidor origen → base de datos → lógica de aplicación → respuesta. El usuario está a 50ms de distancia, pero el origen está en Estambul y la base de datos en Fráncfort — el round-trip comienza en 180ms. Edge SSR invierte esta economía: Cloudflare Workers o Vercel Edge Functions se ejecutan en un PoP (Punto de Presencia) a 15-30ms del usuario. Cuando el KV store está en la misma ubicación edge, la latencia total cae a 40-60ms.",{"type":33,"tag":34,"props":53,"children":54},{},[55],{"type":38,"value":56},"La ganancia no es solo tiempo — el costo de recursos también disminuye. El servidor origen maneja solo mutaciones (POST\u002FPUT\u002FDELETE), el 90% del tráfico GET se cierra en edge. En Vercel Edge, el cold start es 0-5ms; en Cloudflare Workers, 1ms promedio. Comparado con Node.js tradicional, donde un container arranca en 500-1200ms. Esta diferencia impacta directamente la experiencia de primera interacción.",{"type":33,"tag":34,"props":58,"children":59},{},[60],{"type":38,"value":61},"En un sitio de e-commerce, puedes renderizar en edge elementos personalizados como precios específicos del usuario, disponibilidad de stock, contenido del carrito. El esqueleto principal de la página se cachea como HTML estático, solo los bloques dinámicos se rellenan con Edge SSR — la lógica de \"progressive enhancement\". Cuando esta estrategia híbrida alcanza un hit rate de caché del 85%, el TTFB (Tiempo para Primer Byte) cae a 30ms.",{"type":33,"tag":41,"props":63,"children":65},{"id":64},"arquitectura-cloudflare-workers-kv-store",[66],{"type":38,"value":67},"Arquitectura Cloudflare Workers + KV Store",{"type":33,"tag":34,"props":69,"children":70},{},[71],{"type":38,"value":72},"Cloudflare Workers es un runtime basado en V8 isolate — a diferencia de un contenedor tradicional, cada request se ejecuta en un sandbox separado, sin estado compartido. El KV store es un almacenamiento key-value eventualmente consistente y replicado globalmente. Objetivos de latencia: lectura 10-30ms, escritura 100-200ms (debido a replicación asincrónica). Setup:",{"type":33,"tag":74,"props":75,"children":79},"pre",{"className":76,"code":77,"language":78,"meta":17,"style":17},"language-javascript shiki shiki-themes github-dark","\u002F\u002F worker.js — Punto de entrada SSR en edge\nexport default {\n  async fetch(request, env) {\n    const url = new URL(request.url);\n    const userId = getUserId(request); \u002F\u002F Obtén de cookie\n\n    \u002F\u002F Obtén contexto de usuario del KV\n    const userCtx = await env.USER_KV.get(`user:${userId}`, { type: 'json' });\n    \n    if (!userCtx) {\n      return new Response('Unauthorized', { status: 401 });\n    }\n\n    \u002F\u002F Renderiza página personalizada\n    const html = renderPersonalizedPage({\n      userName: userCtx.name,\n      cart: userCtx.cart,\n      recentlyViewed: userCtx.recentlyViewed,\n    });\n\n    return new Response(html, {\n      headers: {\n        'Content-Type': 'text\u002Fhtml;charset=UTF-8',\n        'Cache-Control': 'private, max-age=0',\n      },\n    });\n  },\n};\n\nfunction renderPersonalizedPage(data) {\n  \u002F\u002F Lógica de template simple — en producción, renderiza Vue\u002FReact\n  return `\n    \u003C!DOCTYPE html>\n    \u003Chtml>\n      \u003Chead>\u003Ctitle>Bienvenido ${data.userName}\u003C\u002Ftitle>\u003C\u002Fhead>\n      \u003Cbody>\n        \u003Ch1>Hola ${data.userName}\u003C\u002Fh1>\n        \u003Cp>Tienes ${data.cart.length} artículos en el carrito\u003C\u002Fp>\n        \u003Cul>\n          ${data.recentlyViewed.map(p => `\u003Cli>${p}\u003C\u002Fli>`).join('')}\n        \u003C\u002Ful>\n      \u003C\u002Fbody>\n    \u003C\u002Fhtml>\n  `;\n}\n","javascript",[80],{"type":33,"tag":81,"props":82,"children":83},"code",{"__ignoreMap":17},[84,96,117,158,193,225,235,244,321,329,353,394,403,411,420,447,456,465,474,483,491,513,522,546,568,577,585,594,603,611,637,646,660,669,678,705,714,740,776,785,872,881,890,899,913],{"type":33,"tag":85,"props":86,"children":89},"span",{"class":87,"line":88},"line",1,[90],{"type":33,"tag":85,"props":91,"children":93},{"style":92},"--shiki-default:#6A737D",[94],{"type":38,"value":95},"\u002F\u002F worker.js — Punto de entrada SSR en edge\n",{"type":33,"tag":85,"props":97,"children":99},{"class":87,"line":98},2,[100,106,111],{"type":33,"tag":85,"props":101,"children":103},{"style":102},"--shiki-default:#F97583",[104],{"type":38,"value":105},"export",{"type":33,"tag":85,"props":107,"children":108},{"style":102},[109],{"type":38,"value":110}," default",{"type":33,"tag":85,"props":112,"children":114},{"style":113},"--shiki-default:#E1E4E8",[115],{"type":38,"value":116}," {\n",{"type":33,"tag":85,"props":118,"children":120},{"class":87,"line":119},3,[121,126,132,137,143,148,153],{"type":33,"tag":85,"props":122,"children":123},{"style":102},[124],{"type":38,"value":125},"  async",{"type":33,"tag":85,"props":127,"children":129},{"style":128},"--shiki-default:#B392F0",[130],{"type":38,"value":131}," fetch",{"type":33,"tag":85,"props":133,"children":134},{"style":113},[135],{"type":38,"value":136},"(",{"type":33,"tag":85,"props":138,"children":140},{"style":139},"--shiki-default:#FFAB70",[141],{"type":38,"value":142},"request",{"type":33,"tag":85,"props":144,"children":145},{"style":113},[146],{"type":38,"value":147},", ",{"type":33,"tag":85,"props":149,"children":150},{"style":139},[151],{"type":38,"value":152},"env",{"type":33,"tag":85,"props":154,"children":155},{"style":113},[156],{"type":38,"value":157},") {\n",{"type":33,"tag":85,"props":159,"children":161},{"class":87,"line":160},4,[162,167,173,178,183,188],{"type":33,"tag":85,"props":163,"children":164},{"style":102},[165],{"type":38,"value":166},"    const",{"type":33,"tag":85,"props":168,"children":170},{"style":169},"--shiki-default:#79B8FF",[171],{"type":38,"value":172}," url",{"type":33,"tag":85,"props":174,"children":175},{"style":102},[176],{"type":38,"value":177}," =",{"type":33,"tag":85,"props":179,"children":180},{"style":102},[181],{"type":38,"value":182}," new",{"type":33,"tag":85,"props":184,"children":185},{"style":128},[186],{"type":38,"value":187}," URL",{"type":33,"tag":85,"props":189,"children":190},{"style":113},[191],{"type":38,"value":192},"(request.url);\n",{"type":33,"tag":85,"props":194,"children":196},{"class":87,"line":195},5,[197,201,206,210,215,220],{"type":33,"tag":85,"props":198,"children":199},{"style":102},[200],{"type":38,"value":166},{"type":33,"tag":85,"props":202,"children":203},{"style":169},[204],{"type":38,"value":205}," userId",{"type":33,"tag":85,"props":207,"children":208},{"style":102},[209],{"type":38,"value":177},{"type":33,"tag":85,"props":211,"children":212},{"style":128},[213],{"type":38,"value":214}," getUserId",{"type":33,"tag":85,"props":216,"children":217},{"style":113},[218],{"type":38,"value":219},"(request); ",{"type":33,"tag":85,"props":221,"children":222},{"style":92},[223],{"type":38,"value":224},"\u002F\u002F Obtén de cookie\n",{"type":33,"tag":85,"props":226,"children":228},{"class":87,"line":227},6,[229],{"type":33,"tag":85,"props":230,"children":232},{"emptyLinePlaceholder":231},true,[233],{"type":38,"value":234},"\n",{"type":33,"tag":85,"props":236,"children":238},{"class":87,"line":237},7,[239],{"type":33,"tag":85,"props":240,"children":241},{"style":92},[242],{"type":38,"value":243},"    \u002F\u002F Obtén contexto de usuario del KV\n",{"type":33,"tag":85,"props":245,"children":247},{"class":87,"line":246},8,[248,252,257,261,266,271,276,281,286,290,296,301,306,311,316],{"type":33,"tag":85,"props":249,"children":250},{"style":102},[251],{"type":38,"value":166},{"type":33,"tag":85,"props":253,"children":254},{"style":169},[255],{"type":38,"value":256}," userCtx",{"type":33,"tag":85,"props":258,"children":259},{"style":102},[260],{"type":38,"value":177},{"type":33,"tag":85,"props":262,"children":263},{"style":102},[264],{"type":38,"value":265}," await",{"type":33,"tag":85,"props":267,"children":268},{"style":113},[269],{"type":38,"value":270}," env.",{"type":33,"tag":85,"props":272,"children":273},{"style":169},[274],{"type":38,"value":275},"USER_KV",{"type":33,"tag":85,"props":277,"children":278},{"style":113},[279],{"type":38,"value":280},".",{"type":33,"tag":85,"props":282,"children":283},{"style":128},[284],{"type":38,"value":285},"get",{"type":33,"tag":85,"props":287,"children":288},{"style":113},[289],{"type":38,"value":136},{"type":33,"tag":85,"props":291,"children":293},{"style":292},"--shiki-default:#9ECBFF",[294],{"type":38,"value":295},"`user:${",{"type":33,"tag":85,"props":297,"children":298},{"style":113},[299],{"type":38,"value":300},"userId",{"type":33,"tag":85,"props":302,"children":303},{"style":292},[304],{"type":38,"value":305},"}`",{"type":33,"tag":85,"props":307,"children":308},{"style":113},[309],{"type":38,"value":310},", { type: ",{"type":33,"tag":85,"props":312,"children":313},{"style":292},[314],{"type":38,"value":315},"'json'",{"type":33,"tag":85,"props":317,"children":318},{"style":113},[319],{"type":38,"value":320}," });\n",{"type":33,"tag":85,"props":322,"children":323},{"class":87,"line":27},[324],{"type":33,"tag":85,"props":325,"children":326},{"style":113},[327],{"type":38,"value":328},"    \n",{"type":33,"tag":85,"props":330,"children":332},{"class":87,"line":331},10,[333,338,343,348],{"type":33,"tag":85,"props":334,"children":335},{"style":102},[336],{"type":38,"value":337},"    if",{"type":33,"tag":85,"props":339,"children":340},{"style":113},[341],{"type":38,"value":342}," (",{"type":33,"tag":85,"props":344,"children":345},{"style":102},[346],{"type":38,"value":347},"!",{"type":33,"tag":85,"props":349,"children":350},{"style":113},[351],{"type":38,"value":352},"userCtx) {\n",{"type":33,"tag":85,"props":354,"children":356},{"class":87,"line":355},11,[357,362,366,371,375,380,385,390],{"type":33,"tag":85,"props":358,"children":359},{"style":102},[360],{"type":38,"value":361},"      return",{"type":33,"tag":85,"props":363,"children":364},{"style":102},[365],{"type":38,"value":182},{"type":33,"tag":85,"props":367,"children":368},{"style":128},[369],{"type":38,"value":370}," Response",{"type":33,"tag":85,"props":372,"children":373},{"style":113},[374],{"type":38,"value":136},{"type":33,"tag":85,"props":376,"children":377},{"style":292},[378],{"type":38,"value":379},"'Unauthorized'",{"type":33,"tag":85,"props":381,"children":382},{"style":113},[383],{"type":38,"value":384},", { status: ",{"type":33,"tag":85,"props":386,"children":387},{"style":169},[388],{"type":38,"value":389},"401",{"type":33,"tag":85,"props":391,"children":392},{"style":113},[393],{"type":38,"value":320},{"type":33,"tag":85,"props":395,"children":397},{"class":87,"line":396},12,[398],{"type":33,"tag":85,"props":399,"children":400},{"style":113},[401],{"type":38,"value":402},"    }\n",{"type":33,"tag":85,"props":404,"children":406},{"class":87,"line":405},13,[407],{"type":33,"tag":85,"props":408,"children":409},{"emptyLinePlaceholder":231},[410],{"type":38,"value":234},{"type":33,"tag":85,"props":412,"children":414},{"class":87,"line":413},14,[415],{"type":33,"tag":85,"props":416,"children":417},{"style":92},[418],{"type":38,"value":419},"    \u002F\u002F Renderiza página personalizada\n",{"type":33,"tag":85,"props":421,"children":423},{"class":87,"line":422},15,[424,428,433,437,442],{"type":33,"tag":85,"props":425,"children":426},{"style":102},[427],{"type":38,"value":166},{"type":33,"tag":85,"props":429,"children":430},{"style":169},[431],{"type":38,"value":432}," html",{"type":33,"tag":85,"props":434,"children":435},{"style":102},[436],{"type":38,"value":177},{"type":33,"tag":85,"props":438,"children":439},{"style":128},[440],{"type":38,"value":441}," renderPersonalizedPage",{"type":33,"tag":85,"props":443,"children":444},{"style":113},[445],{"type":38,"value":446},"({\n",{"type":33,"tag":85,"props":448,"children":450},{"class":87,"line":449},16,[451],{"type":33,"tag":85,"props":452,"children":453},{"style":113},[454],{"type":38,"value":455},"      userName: userCtx.name,\n",{"type":33,"tag":85,"props":457,"children":459},{"class":87,"line":458},17,[460],{"type":33,"tag":85,"props":461,"children":462},{"style":113},[463],{"type":38,"value":464},"      cart: userCtx.cart,\n",{"type":33,"tag":85,"props":466,"children":468},{"class":87,"line":467},18,[469],{"type":33,"tag":85,"props":470,"children":471},{"style":113},[472],{"type":38,"value":473},"      recentlyViewed: userCtx.recentlyViewed,\n",{"type":33,"tag":85,"props":475,"children":477},{"class":87,"line":476},19,[478],{"type":33,"tag":85,"props":479,"children":480},{"style":113},[481],{"type":38,"value":482},"    });\n",{"type":33,"tag":85,"props":484,"children":486},{"class":87,"line":485},20,[487],{"type":33,"tag":85,"props":488,"children":489},{"emptyLinePlaceholder":231},[490],{"type":38,"value":234},{"type":33,"tag":85,"props":492,"children":494},{"class":87,"line":493},21,[495,500,504,508],{"type":33,"tag":85,"props":496,"children":497},{"style":102},[498],{"type":38,"value":499},"    return",{"type":33,"tag":85,"props":501,"children":502},{"style":102},[503],{"type":38,"value":182},{"type":33,"tag":85,"props":505,"children":506},{"style":128},[507],{"type":38,"value":370},{"type":33,"tag":85,"props":509,"children":510},{"style":113},[511],{"type":38,"value":512},"(html, {\n",{"type":33,"tag":85,"props":514,"children":516},{"class":87,"line":515},22,[517],{"type":33,"tag":85,"props":518,"children":519},{"style":113},[520],{"type":38,"value":521},"      headers: {\n",{"type":33,"tag":85,"props":523,"children":525},{"class":87,"line":524},23,[526,531,536,541],{"type":33,"tag":85,"props":527,"children":528},{"style":292},[529],{"type":38,"value":530},"        'Content-Type'",{"type":33,"tag":85,"props":532,"children":533},{"style":113},[534],{"type":38,"value":535},": ",{"type":33,"tag":85,"props":537,"children":538},{"style":292},[539],{"type":38,"value":540},"'text\u002Fhtml;charset=UTF-8'",{"type":33,"tag":85,"props":542,"children":543},{"style":113},[544],{"type":38,"value":545},",\n",{"type":33,"tag":85,"props":547,"children":549},{"class":87,"line":548},24,[550,555,559,564],{"type":33,"tag":85,"props":551,"children":552},{"style":292},[553],{"type":38,"value":554},"        'Cache-Control'",{"type":33,"tag":85,"props":556,"children":557},{"style":113},[558],{"type":38,"value":535},{"type":33,"tag":85,"props":560,"children":561},{"style":292},[562],{"type":38,"value":563},"'private, max-age=0'",{"type":33,"tag":85,"props":565,"children":566},{"style":113},[567],{"type":38,"value":545},{"type":33,"tag":85,"props":569,"children":571},{"class":87,"line":570},25,[572],{"type":33,"tag":85,"props":573,"children":574},{"style":113},[575],{"type":38,"value":576},"      },\n",{"type":33,"tag":85,"props":578,"children":580},{"class":87,"line":579},26,[581],{"type":33,"tag":85,"props":582,"children":583},{"style":113},[584],{"type":38,"value":482},{"type":33,"tag":85,"props":586,"children":588},{"class":87,"line":587},27,[589],{"type":33,"tag":85,"props":590,"children":591},{"style":113},[592],{"type":38,"value":593},"  },\n",{"type":33,"tag":85,"props":595,"children":597},{"class":87,"line":596},28,[598],{"type":33,"tag":85,"props":599,"children":600},{"style":113},[601],{"type":38,"value":602},"};\n",{"type":33,"tag":85,"props":604,"children":606},{"class":87,"line":605},29,[607],{"type":33,"tag":85,"props":608,"children":609},{"emptyLinePlaceholder":231},[610],{"type":38,"value":234},{"type":33,"tag":85,"props":612,"children":614},{"class":87,"line":613},30,[615,620,624,628,633],{"type":33,"tag":85,"props":616,"children":617},{"style":102},[618],{"type":38,"value":619},"function",{"type":33,"tag":85,"props":621,"children":622},{"style":128},[623],{"type":38,"value":441},{"type":33,"tag":85,"props":625,"children":626},{"style":113},[627],{"type":38,"value":136},{"type":33,"tag":85,"props":629,"children":630},{"style":139},[631],{"type":38,"value":632},"data",{"type":33,"tag":85,"props":634,"children":635},{"style":113},[636],{"type":38,"value":157},{"type":33,"tag":85,"props":638,"children":640},{"class":87,"line":639},31,[641],{"type":33,"tag":85,"props":642,"children":643},{"style":92},[644],{"type":38,"value":645},"  \u002F\u002F Lógica de template simple — en producción, renderiza Vue\u002FReact\n",{"type":33,"tag":85,"props":647,"children":649},{"class":87,"line":648},32,[650,655],{"type":33,"tag":85,"props":651,"children":652},{"style":102},[653],{"type":38,"value":654},"  return",{"type":33,"tag":85,"props":656,"children":657},{"style":292},[658],{"type":38,"value":659}," `\n",{"type":33,"tag":85,"props":661,"children":663},{"class":87,"line":662},33,[664],{"type":33,"tag":85,"props":665,"children":666},{"style":292},[667],{"type":38,"value":668},"    \u003C!DOCTYPE html>\n",{"type":33,"tag":85,"props":670,"children":672},{"class":87,"line":671},34,[673],{"type":33,"tag":85,"props":674,"children":675},{"style":292},[676],{"type":38,"value":677},"    \u003Chtml>\n",{"type":33,"tag":85,"props":679,"children":681},{"class":87,"line":680},35,[682,687,691,695,700],{"type":33,"tag":85,"props":683,"children":684},{"style":292},[685],{"type":38,"value":686},"      \u003Chead>\u003Ctitle>Bienvenido ${",{"type":33,"tag":85,"props":688,"children":689},{"style":113},[690],{"type":38,"value":632},{"type":33,"tag":85,"props":692,"children":693},{"style":292},[694],{"type":38,"value":280},{"type":33,"tag":85,"props":696,"children":697},{"style":113},[698],{"type":38,"value":699},"userName",{"type":33,"tag":85,"props":701,"children":702},{"style":292},[703],{"type":38,"value":704},"}\u003C\u002Ftitle>\u003C\u002Fhead>\n",{"type":33,"tag":85,"props":706,"children":708},{"class":87,"line":707},36,[709],{"type":33,"tag":85,"props":710,"children":711},{"style":292},[712],{"type":38,"value":713},"      \u003Cbody>\n",{"type":33,"tag":85,"props":715,"children":717},{"class":87,"line":716},37,[718,723,727,731,735],{"type":33,"tag":85,"props":719,"children":720},{"style":292},[721],{"type":38,"value":722},"        \u003Ch1>Hola ${",{"type":33,"tag":85,"props":724,"children":725},{"style":113},[726],{"type":38,"value":632},{"type":33,"tag":85,"props":728,"children":729},{"style":292},[730],{"type":38,"value":280},{"type":33,"tag":85,"props":732,"children":733},{"style":113},[734],{"type":38,"value":699},{"type":33,"tag":85,"props":736,"children":737},{"style":292},[738],{"type":38,"value":739},"}\u003C\u002Fh1>\n",{"type":33,"tag":85,"props":741,"children":743},{"class":87,"line":742},38,[744,749,753,757,762,766,771],{"type":33,"tag":85,"props":745,"children":746},{"style":292},[747],{"type":38,"value":748},"        \u003Cp>Tienes ${",{"type":33,"tag":85,"props":750,"children":751},{"style":113},[752],{"type":38,"value":632},{"type":33,"tag":85,"props":754,"children":755},{"style":292},[756],{"type":38,"value":280},{"type":33,"tag":85,"props":758,"children":759},{"style":113},[760],{"type":38,"value":761},"cart",{"type":33,"tag":85,"props":763,"children":764},{"style":292},[765],{"type":38,"value":280},{"type":33,"tag":85,"props":767,"children":768},{"style":169},[769],{"type":38,"value":770},"length",{"type":33,"tag":85,"props":772,"children":773},{"style":292},[774],{"type":38,"value":775},"} artículos en el carrito\u003C\u002Fp>\n",{"type":33,"tag":85,"props":777,"children":779},{"class":87,"line":778},39,[780],{"type":33,"tag":85,"props":781,"children":782},{"style":292},[783],{"type":38,"value":784},"        \u003Cul>\n",{"type":33,"tag":85,"props":786,"children":788},{"class":87,"line":787},40,[789,794,798,802,807,811,816,820,824,829,834,838,843,848,853,857,862,867],{"type":33,"tag":85,"props":790,"children":791},{"style":292},[792],{"type":38,"value":793},"          ${",{"type":33,"tag":85,"props":795,"children":796},{"style":113},[797],{"type":38,"value":632},{"type":33,"tag":85,"props":799,"children":800},{"style":292},[801],{"type":38,"value":280},{"type":33,"tag":85,"props":803,"children":804},{"style":113},[805],{"type":38,"value":806},"recentlyViewed",{"type":33,"tag":85,"props":808,"children":809},{"style":292},[810],{"type":38,"value":280},{"type":33,"tag":85,"props":812,"children":813},{"style":128},[814],{"type":38,"value":815},"map",{"type":33,"tag":85,"props":817,"children":818},{"style":292},[819],{"type":38,"value":136},{"type":33,"tag":85,"props":821,"children":822},{"style":169},[823],{"type":38,"value":34},{"type":33,"tag":85,"props":825,"children":826},{"style":102},[827],{"type":38,"value":828}," =>",{"type":33,"tag":85,"props":830,"children":831},{"style":292},[832],{"type":38,"value":833}," `\u003Cli>${",{"type":33,"tag":85,"props":835,"children":836},{"style":113},[837],{"type":38,"value":34},{"type":33,"tag":85,"props":839,"children":840},{"style":292},[841],{"type":38,"value":842},"}\u003C\u002Fli>`",{"type":33,"tag":85,"props":844,"children":845},{"style":292},[846],{"type":38,"value":847},").",{"type":33,"tag":85,"props":849,"children":850},{"style":128},[851],{"type":38,"value":852},"join",{"type":33,"tag":85,"props":854,"children":855},{"style":292},[856],{"type":38,"value":136},{"type":33,"tag":85,"props":858,"children":859},{"style":292},[860],{"type":38,"value":861},"''",{"type":33,"tag":85,"props":863,"children":864},{"style":292},[865],{"type":38,"value":866},")",{"type":33,"tag":85,"props":868,"children":869},{"style":292},[870],{"type":38,"value":871},"}\n",{"type":33,"tag":85,"props":873,"children":875},{"class":87,"line":874},41,[876],{"type":33,"tag":85,"props":877,"children":878},{"style":292},[879],{"type":38,"value":880},"        \u003C\u002Ful>\n",{"type":33,"tag":85,"props":882,"children":884},{"class":87,"line":883},42,[885],{"type":33,"tag":85,"props":886,"children":887},{"style":292},[888],{"type":38,"value":889},"      \u003C\u002Fbody>\n",{"type":33,"tag":85,"props":891,"children":893},{"class":87,"line":892},43,[894],{"type":33,"tag":85,"props":895,"children":896},{"style":292},[897],{"type":38,"value":898},"    \u003C\u002Fhtml>\n",{"type":33,"tag":85,"props":900,"children":902},{"class":87,"line":901},44,[903,908],{"type":33,"tag":85,"props":904,"children":905},{"style":292},[906],{"type":38,"value":907},"  `",{"type":33,"tag":85,"props":909,"children":910},{"style":113},[911],{"type":38,"value":912},";\n",{"type":33,"tag":85,"props":914,"children":916},{"class":87,"line":915},45,[917],{"type":33,"tag":85,"props":918,"children":919},{"style":113},[920],{"type":38,"value":871},{"type":33,"tag":34,"props":922,"children":923},{},[924],{"type":33,"tag":925,"props":926,"children":927},"strong",{},[928],{"type":38,"value":929},"Estructura de datos KV:",{"type":33,"tag":931,"props":932,"children":933},"ul",{},[934,946,957],{"type":33,"tag":935,"props":936,"children":937},"li",{},[938,940],{"type":38,"value":939},"Key: ",{"type":33,"tag":81,"props":941,"children":943},{"className":942},[],[944],{"type":38,"value":945},"user:{userId}",{"type":33,"tag":935,"props":947,"children":948},{},[949,951],{"type":38,"value":950},"Value: JSON — ",{"type":33,"tag":81,"props":952,"children":954},{"className":953},[],[955],{"type":38,"value":956},"{ name, cart, recentlyViewed, priceTier }",{"type":33,"tag":935,"props":958,"children":959},{},[960],{"type":38,"value":961},"TTL: 3600s (cache de 1 hora, después refresh desde origen)",{"type":33,"tag":34,"props":963,"children":964},{},[965],{"type":38,"value":966},"Con este setup, cada lectura toma 15-25ms — sin viajes de red a Postgres en Fráncfort. La ruta de escritura es diferente: cuando llega una mutación, POST a la API de origen, que actualiza tanto la base de datos como escribe en KV de forma asincrónica. La consistencia eventual de KV significa que todos los nodos edge verán los nuevos datos 100ms después de la escritura.",{"type":33,"tag":968,"props":969,"children":971},"h3",{"id":970},"alternativa-vercel-edge-functions",[972],{"type":38,"value":973},"Alternativa: Vercel Edge Functions",{"type":33,"tag":34,"props":975,"children":976},{},[977],{"type":38,"value":978},"Vercel Edge está integrado nativamente con Next.js — opera como middleware. Setup:",{"type":33,"tag":74,"props":980,"children":984},{"className":981,"code":982,"language":983,"meta":17,"style":17},"language-typescript shiki shiki-themes github-dark","\u002F\u002F middleware.ts\nimport { NextRequest, NextResponse } from 'next\u002Fserver';\n\nexport async function middleware(req: NextRequest) {\n  const userId = req.cookies.get('userId')?.value;\n  \n  if (!userId) {\n    return NextResponse.redirect(new URL('\u002Flogin', req.url));\n  }\n\n  \u002F\u002F Vercel KV (compatible con Redis, infraestructura Upstash)\n  const userCtx = await fetch(`https:\u002F\u002FYOUR_KV_ENDPOINT\u002Fget\u002Fuser:${userId}`);\n  const data = await userCtx.json();\n\n  \u002F\u002F Agrega contexto al header de request, pasa al siguiente manejador\n  const response = NextResponse.next();\n  response.headers.set('X-User-Context', JSON.stringify(data));\n  \n  return response;\n}\n\nexport const config = {\n  matcher: ['\u002Fdashboard\u002F:path*', '\u002Fcheckout\u002F:path*'],\n};\n","typescript",[985],{"type":33,"tag":81,"props":986,"children":987},{"__ignoreMap":17},[988,996,1023,1030,1075,1114,1122,1143,1187,1195,1202,1210,1255,1290,1297,1305,1334,1379,1386,1398,1405,1412,1437,1464],{"type":33,"tag":85,"props":989,"children":990},{"class":87,"line":88},[991],{"type":33,"tag":85,"props":992,"children":993},{"style":92},[994],{"type":38,"value":995},"\u002F\u002F middleware.ts\n",{"type":33,"tag":85,"props":997,"children":998},{"class":87,"line":98},[999,1004,1009,1014,1019],{"type":33,"tag":85,"props":1000,"children":1001},{"style":102},[1002],{"type":38,"value":1003},"import",{"type":33,"tag":85,"props":1005,"children":1006},{"style":113},[1007],{"type":38,"value":1008}," { NextRequest, NextResponse } ",{"type":33,"tag":85,"props":1010,"children":1011},{"style":102},[1012],{"type":38,"value":1013},"from",{"type":33,"tag":85,"props":1015,"children":1016},{"style":292},[1017],{"type":38,"value":1018}," 'next\u002Fserver'",{"type":33,"tag":85,"props":1020,"children":1021},{"style":113},[1022],{"type":38,"value":912},{"type":33,"tag":85,"props":1024,"children":1025},{"class":87,"line":119},[1026],{"type":33,"tag":85,"props":1027,"children":1028},{"emptyLinePlaceholder":231},[1029],{"type":38,"value":234},{"type":33,"tag":85,"props":1031,"children":1032},{"class":87,"line":160},[1033,1037,1042,1047,1052,1056,1061,1066,1071],{"type":33,"tag":85,"props":1034,"children":1035},{"style":102},[1036],{"type":38,"value":105},{"type":33,"tag":85,"props":1038,"children":1039},{"style":102},[1040],{"type":38,"value":1041}," async",{"type":33,"tag":85,"props":1043,"children":1044},{"style":102},[1045],{"type":38,"value":1046}," function",{"type":33,"tag":85,"props":1048,"children":1049},{"style":128},[1050],{"type":38,"value":1051}," middleware",{"type":33,"tag":85,"props":1053,"children":1054},{"style":113},[1055],{"type":38,"value":136},{"type":33,"tag":85,"props":1057,"children":1058},{"style":139},[1059],{"type":38,"value":1060},"req",{"type":33,"tag":85,"props":1062,"children":1063},{"style":102},[1064],{"type":38,"value":1065},":",{"type":33,"tag":85,"props":1067,"children":1068},{"style":128},[1069],{"type":38,"value":1070}," NextRequest",{"type":33,"tag":85,"props":1072,"children":1073},{"style":113},[1074],{"type":38,"value":157},{"type":33,"tag":85,"props":1076,"children":1077},{"class":87,"line":195},[1078,1083,1087,1091,1096,1100,1104,1109],{"type":33,"tag":85,"props":1079,"children":1080},{"style":102},[1081],{"type":38,"value":1082},"  const",{"type":33,"tag":85,"props":1084,"children":1085},{"style":169},[1086],{"type":38,"value":205},{"type":33,"tag":85,"props":1088,"children":1089},{"style":102},[1090],{"type":38,"value":177},{"type":33,"tag":85,"props":1092,"children":1093},{"style":113},[1094],{"type":38,"value":1095}," req.cookies.",{"type":33,"tag":85,"props":1097,"children":1098},{"style":128},[1099],{"type":38,"value":285},{"type":33,"tag":85,"props":1101,"children":1102},{"style":113},[1103],{"type":38,"value":136},{"type":33,"tag":85,"props":1105,"children":1106},{"style":292},[1107],{"type":38,"value":1108},"'userId'",{"type":33,"tag":85,"props":1110,"children":1111},{"style":113},[1112],{"type":38,"value":1113},")?.value;\n",{"type":33,"tag":85,"props":1115,"children":1116},{"class":87,"line":227},[1117],{"type":33,"tag":85,"props":1118,"children":1119},{"style":113},[1120],{"type":38,"value":1121},"  \n",{"type":33,"tag":85,"props":1123,"children":1124},{"class":87,"line":237},[1125,1130,1134,1138],{"type":33,"tag":85,"props":1126,"children":1127},{"style":102},[1128],{"type":38,"value":1129},"  if",{"type":33,"tag":85,"props":1131,"children":1132},{"style":113},[1133],{"type":38,"value":342},{"type":33,"tag":85,"props":1135,"children":1136},{"style":102},[1137],{"type":38,"value":347},{"type":33,"tag":85,"props":1139,"children":1140},{"style":113},[1141],{"type":38,"value":1142},"userId) {\n",{"type":33,"tag":85,"props":1144,"children":1145},{"class":87,"line":246},[1146,1150,1155,1160,1164,1169,1173,1177,1182],{"type":33,"tag":85,"props":1147,"children":1148},{"style":102},[1149],{"type":38,"value":499},{"type":33,"tag":85,"props":1151,"children":1152},{"style":113},[1153],{"type":38,"value":1154}," NextResponse.",{"type":33,"tag":85,"props":1156,"children":1157},{"style":128},[1158],{"type":38,"value":1159},"redirect",{"type":33,"tag":85,"props":1161,"children":1162},{"style":113},[1163],{"type":38,"value":136},{"type":33,"tag":85,"props":1165,"children":1166},{"style":102},[1167],{"type":38,"value":1168},"new",{"type":33,"tag":85,"props":1170,"children":1171},{"style":128},[1172],{"type":38,"value":187},{"type":33,"tag":85,"props":1174,"children":1175},{"style":113},[1176],{"type":38,"value":136},{"type":33,"tag":85,"props":1178,"children":1179},{"style":292},[1180],{"type":38,"value":1181},"'\u002Flogin'",{"type":33,"tag":85,"props":1183,"children":1184},{"style":113},[1185],{"type":38,"value":1186},", req.url));\n",{"type":33,"tag":85,"props":1188,"children":1189},{"class":87,"line":27},[1190],{"type":33,"tag":85,"props":1191,"children":1192},{"style":113},[1193],{"type":38,"value":1194},"  }\n",{"type":33,"tag":85,"props":1196,"children":1197},{"class":87,"line":331},[1198],{"type":33,"tag":85,"props":1199,"children":1200},{"emptyLinePlaceholder":231},[1201],{"type":38,"value":234},{"type":33,"tag":85,"props":1203,"children":1204},{"class":87,"line":355},[1205],{"type":33,"tag":85,"props":1206,"children":1207},{"style":92},[1208],{"type":38,"value":1209},"  \u002F\u002F Vercel KV (compatible con Redis, infraestructura Upstash)\n",{"type":33,"tag":85,"props":1211,"children":1212},{"class":87,"line":396},[1213,1217,1221,1225,1229,1233,1237,1242,1246,1250],{"type":33,"tag":85,"props":1214,"children":1215},{"style":102},[1216],{"type":38,"value":1082},{"type":33,"tag":85,"props":1218,"children":1219},{"style":169},[1220],{"type":38,"value":256},{"type":33,"tag":85,"props":1222,"children":1223},{"style":102},[1224],{"type":38,"value":177},{"type":33,"tag":85,"props":1226,"children":1227},{"style":102},[1228],{"type":38,"value":265},{"type":33,"tag":85,"props":1230,"children":1231},{"style":128},[1232],{"type":38,"value":131},{"type":33,"tag":85,"props":1234,"children":1235},{"style":113},[1236],{"type":38,"value":136},{"type":33,"tag":85,"props":1238,"children":1239},{"style":292},[1240],{"type":38,"value":1241},"`https:\u002F\u002FYOUR_KV_ENDPOINT\u002Fget\u002Fuser:${",{"type":33,"tag":85,"props":1243,"children":1244},{"style":113},[1245],{"type":38,"value":300},{"type":33,"tag":85,"props":1247,"children":1248},{"style":292},[1249],{"type":38,"value":305},{"type":33,"tag":85,"props":1251,"children":1252},{"style":113},[1253],{"type":38,"value":1254},");\n",{"type":33,"tag":85,"props":1256,"children":1257},{"class":87,"line":405},[1258,1262,1267,1271,1275,1280,1285],{"type":33,"tag":85,"props":1259,"children":1260},{"style":102},[1261],{"type":38,"value":1082},{"type":33,"tag":85,"props":1263,"children":1264},{"style":169},[1265],{"type":38,"value":1266}," data",{"type":33,"tag":85,"props":1268,"children":1269},{"style":102},[1270],{"type":38,"value":177},{"type":33,"tag":85,"props":1272,"children":1273},{"style":102},[1274],{"type":38,"value":265},{"type":33,"tag":85,"props":1276,"children":1277},{"style":113},[1278],{"type":38,"value":1279}," userCtx.",{"type":33,"tag":85,"props":1281,"children":1282},{"style":128},[1283],{"type":38,"value":1284},"json",{"type":33,"tag":85,"props":1286,"children":1287},{"style":113},[1288],{"type":38,"value":1289},"();\n",{"type":33,"tag":85,"props":1291,"children":1292},{"class":87,"line":413},[1293],{"type":33,"tag":85,"props":1294,"children":1295},{"emptyLinePlaceholder":231},[1296],{"type":38,"value":234},{"type":33,"tag":85,"props":1298,"children":1299},{"class":87,"line":422},[1300],{"type":33,"tag":85,"props":1301,"children":1302},{"style":92},[1303],{"type":38,"value":1304},"  \u002F\u002F Agrega contexto al header de request, pasa al siguiente manejador\n",{"type":33,"tag":85,"props":1306,"children":1307},{"class":87,"line":449},[1308,1312,1317,1321,1325,1330],{"type":33,"tag":85,"props":1309,"children":1310},{"style":102},[1311],{"type":38,"value":1082},{"type":33,"tag":85,"props":1313,"children":1314},{"style":169},[1315],{"type":38,"value":1316}," response",{"type":33,"tag":85,"props":1318,"children":1319},{"style":102},[1320],{"type":38,"value":177},{"type":33,"tag":85,"props":1322,"children":1323},{"style":113},[1324],{"type":38,"value":1154},{"type":33,"tag":85,"props":1326,"children":1327},{"style":128},[1328],{"type":38,"value":1329},"next",{"type":33,"tag":85,"props":1331,"children":1332},{"style":113},[1333],{"type":38,"value":1289},{"type":33,"tag":85,"props":1335,"children":1336},{"class":87,"line":458},[1337,1342,1347,1351,1356,1360,1365,1369,1374],{"type":33,"tag":85,"props":1338,"children":1339},{"style":113},[1340],{"type":38,"value":1341},"  response.headers.",{"type":33,"tag":85,"props":1343,"children":1344},{"style":128},[1345],{"type":38,"value":1346},"set",{"type":33,"tag":85,"props":1348,"children":1349},{"style":113},[1350],{"type":38,"value":136},{"type":33,"tag":85,"props":1352,"children":1353},{"style":292},[1354],{"type":38,"value":1355},"'X-User-Context'",{"type":33,"tag":85,"props":1357,"children":1358},{"style":113},[1359],{"type":38,"value":147},{"type":33,"tag":85,"props":1361,"children":1362},{"style":169},[1363],{"type":38,"value":1364},"JSON",{"type":33,"tag":85,"props":1366,"children":1367},{"style":113},[1368],{"type":38,"value":280},{"type":33,"tag":85,"props":1370,"children":1371},{"style":128},[1372],{"type":38,"value":1373},"stringify",{"type":33,"tag":85,"props":1375,"children":1376},{"style":113},[1377],{"type":38,"value":1378},"(data));\n",{"type":33,"tag":85,"props":1380,"children":1381},{"class":87,"line":467},[1382],{"type":33,"tag":85,"props":1383,"children":1384},{"style":113},[1385],{"type":38,"value":1121},{"type":33,"tag":85,"props":1387,"children":1388},{"class":87,"line":476},[1389,1393],{"type":33,"tag":85,"props":1390,"children":1391},{"style":102},[1392],{"type":38,"value":654},{"type":33,"tag":85,"props":1394,"children":1395},{"style":113},[1396],{"type":38,"value":1397}," response;\n",{"type":33,"tag":85,"props":1399,"children":1400},{"class":87,"line":485},[1401],{"type":33,"tag":85,"props":1402,"children":1403},{"style":113},[1404],{"type":38,"value":871},{"type":33,"tag":85,"props":1406,"children":1407},{"class":87,"line":493},[1408],{"type":33,"tag":85,"props":1409,"children":1410},{"emptyLinePlaceholder":231},[1411],{"type":38,"value":234},{"type":33,"tag":85,"props":1413,"children":1414},{"class":87,"line":515},[1415,1419,1424,1429,1433],{"type":33,"tag":85,"props":1416,"children":1417},{"style":102},[1418],{"type":38,"value":105},{"type":33,"tag":85,"props":1420,"children":1421},{"style":102},[1422],{"type":38,"value":1423}," const",{"type":33,"tag":85,"props":1425,"children":1426},{"style":169},[1427],{"type":38,"value":1428}," config",{"type":33,"tag":85,"props":1430,"children":1431},{"style":102},[1432],{"type":38,"value":177},{"type":33,"tag":85,"props":1434,"children":1435},{"style":113},[1436],{"type":38,"value":116},{"type":33,"tag":85,"props":1438,"children":1439},{"class":87,"line":524},[1440,1445,1450,1454,1459],{"type":33,"tag":85,"props":1441,"children":1442},{"style":113},[1443],{"type":38,"value":1444},"  matcher: [",{"type":33,"tag":85,"props":1446,"children":1447},{"style":292},[1448],{"type":38,"value":1449},"'\u002Fdashboard\u002F:path*'",{"type":33,"tag":85,"props":1451,"children":1452},{"style":113},[1453],{"type":38,"value":147},{"type":33,"tag":85,"props":1455,"children":1456},{"style":292},[1457],{"type":38,"value":1458},"'\u002Fcheckout\u002F:path*'",{"type":33,"tag":85,"props":1460,"children":1461},{"style":113},[1462],{"type":38,"value":1463},"],\n",{"type":33,"tag":85,"props":1465,"children":1466},{"class":87,"line":548},[1467],{"type":33,"tag":85,"props":1468,"children":1469},{"style":113},[1470],{"type":38,"value":602},{"type":33,"tag":34,"props":1472,"children":1473},{},[1474],{"type":38,"value":1475},"En Vercel Edge, el cold start es 3-8ms, ligeramente más lento que Cloudflare, pero la integración con ISR (Regeneración Estática Incremental) de Next.js es robusta. Puedes generar una página de forma estática e enriquecerla en edge con contexto de usuario — la lógica de \"streaming SSR\". Ejemplo: el layout principal es HTML estático, el widget del usuario se inyecta en edge.",{"type":33,"tag":41,"props":1477,"children":1479},{"id":1478},"tradeoffs-tamaño-de-bundle-debugging-costo",[1480],{"type":38,"value":1481},"Tradeoffs: Tamaño de Bundle, Debugging, Costo",{"type":33,"tag":34,"props":1483,"children":1484},{},[1485,1487,1493,1494,1500,1502,1508,1510,1516,1518,1524],{"type":38,"value":1486},"El runtime edge es limitado — no tienes acceso a la API completa de Node.js. En Cloudflare Workers no corren módulos nativos de Node (como ",{"type":33,"tag":81,"props":1488,"children":1490},{"className":1489},[],[1491],{"type":38,"value":1492},"fs",{"type":38,"value":147},{"type":33,"tag":81,"props":1495,"children":1497},{"className":1496},[],[1498],{"type":38,"value":1499},"child_process",{"type":38,"value":1501},"), lo mismo en Vercel Edge. Necesitas minimizar dependencias. Ejemplo: ",{"type":33,"tag":81,"props":1503,"children":1505},{"className":1504},[],[1506],{"type":38,"value":1507},"date-fns",{"type":38,"value":1509}," (70KB) en lugar de ",{"type":33,"tag":81,"props":1511,"children":1513},{"className":1512},[],[1514],{"type":38,"value":1515},"dayjs",{"type":38,"value":1517}," (2KB), ",{"type":33,"tag":81,"props":1519,"children":1521},{"className":1520},[],[1522],{"type":38,"value":1523},"lodash",{"type":38,"value":1525}," reemplazado por métodos ES6 nativos.",{"type":33,"tag":34,"props":1527,"children":1528},{},[1529],{"type":33,"tag":925,"props":1530,"children":1531},{},[1532],{"type":38,"value":1533},"Límites de tamaño de bundle:",{"type":33,"tag":931,"props":1535,"children":1536},{},[1537,1542],{"type":33,"tag":935,"props":1538,"children":1539},{},[1540],{"type":38,"value":1541},"Cloudflare Workers: 1MB (comprimido 5MB)",{"type":33,"tag":935,"props":1543,"children":1544},{},[1545],{"type":38,"value":1546},"Vercel Edge: 1MB (middleware)",{"type":33,"tag":34,"props":1548,"children":1549},{},[1550,1552,1558],{"type":38,"value":1551},"En producción, no deberías exceder 200KB — cada KB agrega 0.5-1ms de latencia (parse + ejecución). Tree-shaking y code splitting son críticos. Si usas React, ",{"type":33,"tag":81,"props":1553,"children":1555},{"className":1554},[],[1556],{"type":38,"value":1557},"preact",{"type":38,"value":1559}," (3KB) es más sensato.",{"type":33,"tag":34,"props":1561,"children":1562},{},[1563,1568,1570,1576,1578,1584,1586,1592],{"type":33,"tag":925,"props":1564,"children":1565},{},[1566],{"type":38,"value":1567},"Debugging:",{"type":38,"value":1569}," Edge tiene ",{"type":33,"tag":81,"props":1571,"children":1573},{"className":1572},[],[1574],{"type":38,"value":1575},"console.log",{"type":38,"value":1577},", pero faltan stack traces completos. Con Cloudflare Wrangler CLI puedes configurar un entorno de test local (",{"type":33,"tag":81,"props":1579,"children":1581},{"className":1580},[],[1582],{"type":38,"value":1583},"wrangler dev",{"type":38,"value":1585},"). En Vercel, ",{"type":33,"tag":81,"props":1587,"children":1589},{"className":1588},[],[1590],{"type":38,"value":1591},"vercel dev",{"type":38,"value":1593}," simula el runtime edge. En producción, un servicio como Sentry es obligatorio — envías logs de error con HTTP POST desde el isolate edge.",{"type":33,"tag":34,"props":1595,"children":1596},{},[1597,1602],{"type":33,"tag":925,"props":1598,"children":1599},{},[1600],{"type":38,"value":1601},"Costo:",{"type":38,"value":1603}," Cloudflare Workers: primeros 100K requests\u002Fdía gratis, después $0.50\u002Fmillón. KV store: primer 1GB gratis, luego $0.50\u002F10 millones de lecturas. Vercel Edge está en el plan — Pro plan incluye 1 millón de ejecuciones. Para 10 millones de requests\u002Fmes, el costo edge es $20-40\u002Fmes; con infraestructura tradicional, el mismo tráfico cuesta $150-200\u002Fmes en servidor. A mayor escala, la ventaja aumenta.",{"type":33,"tag":41,"props":1605,"children":1607},{"id":1606},"estrategia-kv-store-write-through-vs-write-behind",[1608],{"type":38,"value":1609},"Estrategia KV Store: Write-Through vs Write-Behind",{"type":33,"tag":34,"props":1611,"children":1612},{},[1613],{"type":38,"value":1614},"Cómo escribas en KV impacta directamente la latencia. Dos patrones:",{"type":33,"tag":34,"props":1616,"children":1617},{},[1618,1623],{"type":33,"tag":925,"props":1619,"children":1620},{},[1621],{"type":38,"value":1622},"Write-Through (Síncrono):",{"type":38,"value":1624},"\nCuando el API de origen recibe una mutación, escribe tanto en DB como en KV, devuelve respuesta cuando ambos están ok. Garantía de consistencia, pero latencia de escritura 150-250ms (dos saltos de red).",{"type":33,"tag":74,"props":1626,"children":1628},{"className":76,"code":1627,"language":78,"meta":17,"style":17},"\u002F\u002F Manejador de API de origen\napp.post('\u002Fcart\u002Fadd', async (req, res) => {\n  const { userId, productId } = req.body;\n  \n  \u002F\u002F 1. Escribe en Postgres\n  await db.query('INSERT INTO cart_items ...');\n  \n  \u002F\u002F 2. Actualiza KV\n  const userCtx = await getUserContext(userId);\n  userCtx.cart.push(productId);\n  await kv.put(`user:${userId}`, JSON.stringify(userCtx));\n  \n  res.json({ success: true });\n});\n",[1629],{"type":33,"tag":81,"props":1630,"children":1631},{"__ignoreMap":17},[1632,1640,1702,1742,1749,1757,1788,1795,1803,1832,1850,1904,1911,1937],{"type":33,"tag":85,"props":1633,"children":1634},{"class":87,"line":88},[1635],{"type":33,"tag":85,"props":1636,"children":1637},{"style":92},[1638],{"type":38,"value":1639},"\u002F\u002F Manejador de API de origen\n",{"type":33,"tag":85,"props":1641,"children":1642},{"class":87,"line":98},[1643,1648,1653,1657,1662,1666,1671,1675,1679,1683,1688,1693,1698],{"type":33,"tag":85,"props":1644,"children":1645},{"style":113},[1646],{"type":38,"value":1647},"app.",{"type":33,"tag":85,"props":1649,"children":1650},{"style":128},[1651],{"type":38,"value":1652},"post",{"type":33,"tag":85,"props":1654,"children":1655},{"style":113},[1656],{"type":38,"value":136},{"type":33,"tag":85,"props":1658,"children":1659},{"style":292},[1660],{"type":38,"value":1661},"'\u002Fcart\u002Fadd'",{"type":33,"tag":85,"props":1663,"children":1664},{"style":113},[1665],{"type":38,"value":147},{"type":33,"tag":85,"props":1667,"children":1668},{"style":102},[1669],{"type":38,"value":1670},"async",{"type":33,"tag":85,"props":1672,"children":1673},{"style":113},[1674],{"type":38,"value":342},{"type":33,"tag":85,"props":1676,"children":1677},{"style":139},[1678],{"type":38,"value":1060},{"type":33,"tag":85,"props":1680,"children":1681},{"style":113},[1682],{"type":38,"value":147},{"type":33,"tag":85,"props":1684,"children":1685},{"style":139},[1686],{"type":38,"value":1687},"res",{"type":33,"tag":85,"props":1689,"children":1690},{"style":113},[1691],{"type":38,"value":1692},") ",{"type":33,"tag":85,"props":1694,"children":1695},{"style":102},[1696],{"type":38,"value":1697},"=>",{"type":33,"tag":85,"props":1699,"children":1700},{"style":113},[1701],{"type":38,"value":116},{"type":33,"tag":85,"props":1703,"children":1704},{"class":87,"line":119},[1705,1709,1714,1718,1722,1727,1732,1737],{"type":33,"tag":85,"props":1706,"children":1707},{"style":102},[1708],{"type":38,"value":1082},{"type":33,"tag":85,"props":1710,"children":1711},{"style":113},[1712],{"type":38,"value":1713}," { ",{"type":33,"tag":85,"props":1715,"children":1716},{"style":169},[1717],{"type":38,"value":300},{"type":33,"tag":85,"props":1719,"children":1720},{"style":113},[1721],{"type":38,"value":147},{"type":33,"tag":85,"props":1723,"children":1724},{"style":169},[1725],{"type":38,"value":1726},"productId",{"type":33,"tag":85,"props":1728,"children":1729},{"style":113},[1730],{"type":38,"value":1731}," } ",{"type":33,"tag":85,"props":1733,"children":1734},{"style":102},[1735],{"type":38,"value":1736},"=",{"type":33,"tag":85,"props":1738,"children":1739},{"style":113},[1740],{"type":38,"value":1741}," req.body;\n",{"type":33,"tag":85,"props":1743,"children":1744},{"class":87,"line":160},[1745],{"type":33,"tag":85,"props":1746,"children":1747},{"style":113},[1748],{"type":38,"value":1121},{"type":33,"tag":85,"props":1750,"children":1751},{"class":87,"line":195},[1752],{"type":33,"tag":85,"props":1753,"children":1754},{"style":92},[1755],{"type":38,"value":1756},"  \u002F\u002F 1. Escribe en Postgres\n",{"type":33,"tag":85,"props":1758,"children":1759},{"class":87,"line":227},[1760,1765,1770,1775,1779,1784],{"type":33,"tag":85,"props":1761,"children":1762},{"style":102},[1763],{"type":38,"value":1764},"  await",{"type":33,"tag":85,"props":1766,"children":1767},{"style":113},[1768],{"type":38,"value":1769}," db.",{"type":33,"tag":85,"props":1771,"children":1772},{"style":128},[1773],{"type":38,"value":1774},"query",{"type":33,"tag":85,"props":1776,"children":1777},{"style":113},[1778],{"type":38,"value":136},{"type":33,"tag":85,"props":1780,"children":1781},{"style":292},[1782],{"type":38,"value":1783},"'INSERT INTO cart_items ...'",{"type":33,"tag":85,"props":1785,"children":1786},{"style":113},[1787],{"type":38,"value":1254},{"type":33,"tag":85,"props":1789,"children":1790},{"class":87,"line":237},[1791],{"type":33,"tag":85,"props":1792,"children":1793},{"style":113},[1794],{"type":38,"value":1121},{"type":33,"tag":85,"props":1796,"children":1797},{"class":87,"line":246},[1798],{"type":33,"tag":85,"props":1799,"children":1800},{"style":92},[1801],{"type":38,"value":1802},"  \u002F\u002F 2. Actualiza KV\n",{"type":33,"tag":85,"props":1804,"children":1805},{"class":87,"line":27},[1806,1810,1814,1818,1822,1827],{"type":33,"tag":85,"props":1807,"children":1808},{"style":102},[1809],{"type":38,"value":1082},{"type":33,"tag":85,"props":1811,"children":1812},{"style":169},[1813],{"type":38,"value":256},{"type":33,"tag":85,"props":1815,"children":1816},{"style":102},[1817],{"type":38,"value":177},{"type":33,"tag":85,"props":1819,"children":1820},{"style":102},[1821],{"type":38,"value":265},{"type":33,"tag":85,"props":1823,"children":1824},{"style":128},[1825],{"type":38,"value":1826}," getUserContext",{"type":33,"tag":85,"props":1828,"children":1829},{"style":113},[1830],{"type":38,"value":1831},"(userId);\n",{"type":33,"tag":85,"props":1833,"children":1834},{"class":87,"line":331},[1835,1840,1845],{"type":33,"tag":85,"props":1836,"children":1837},{"style":113},[1838],{"type":38,"value":1839},"  userCtx.cart.",{"type":33,"tag":85,"props":1841,"children":1842},{"style":128},[1843],{"type":38,"value":1844},"push",{"type":33,"tag":85,"props":1846,"children":1847},{"style":113},[1848],{"type":38,"value":1849},"(productId);\n",{"type":33,"tag":85,"props":1851,"children":1852},{"class":87,"line":355},[1853,1857,1862,1867,1871,1875,1879,1883,1887,1891,1895,1899],{"type":33,"tag":85,"props":1854,"children":1855},{"style":102},[1856],{"type":38,"value":1764},{"type":33,"tag":85,"props":1858,"children":1859},{"style":113},[1860],{"type":38,"value":1861}," kv.",{"type":33,"tag":85,"props":1863,"children":1864},{"style":128},[1865],{"type":38,"value":1866},"put",{"type":33,"tag":85,"props":1868,"children":1869},{"style":113},[1870],{"type":38,"value":136},{"type":33,"tag":85,"props":1872,"children":1873},{"style":292},[1874],{"type":38,"value":295},{"type":33,"tag":85,"props":1876,"children":1877},{"style":113},[1878],{"type":38,"value":300},{"type":33,"tag":85,"props":1880,"children":1881},{"style":292},[1882],{"type":38,"value":305},{"type":33,"tag":85,"props":1884,"children":1885},{"style":113},[1886],{"type":38,"value":147},{"type":33,"tag":85,"props":1888,"children":1889},{"style":169},[1890],{"type":38,"value":1364},{"type":33,"tag":85,"props":1892,"children":1893},{"style":113},[1894],{"type":38,"value":280},{"type":33,"tag":85,"props":1896,"children":1897},{"style":128},[1898],{"type":38,"value":1373},{"type":33,"tag":85,"props":1900,"children":1901},{"style":113},[1902],{"type":38,"value":1903},"(userCtx));\n",{"type":33,"tag":85,"props":1905,"children":1906},{"class":87,"line":396},[1907],{"type":33,"tag":85,"props":1908,"children":1909},{"style":113},[1910],{"type":38,"value":1121},{"type":33,"tag":85,"props":1912,"children":1913},{"class":87,"line":405},[1914,1919,1923,1928,1933],{"type":33,"tag":85,"props":1915,"children":1916},{"style":113},[1917],{"type":38,"value":1918},"  res.",{"type":33,"tag":85,"props":1920,"children":1921},{"style":128},[1922],{"type":38,"value":1284},{"type":33,"tag":85,"props":1924,"children":1925},{"style":113},[1926],{"type":38,"value":1927},"({ success: ",{"type":33,"tag":85,"props":1929,"children":1930},{"style":169},[1931],{"type":38,"value":1932},"true",{"type":33,"tag":85,"props":1934,"children":1935},{"style":113},[1936],{"type":38,"value":320},{"type":33,"tag":85,"props":1938,"children":1939},{"class":87,"line":413},[1940],{"type":33,"tag":85,"props":1941,"children":1942},{"style":113},[1943],{"type":38,"value":1944},"});\n",{"type":33,"tag":34,"props":1946,"children":1947},{},[1948,1953],{"type":33,"tag":925,"props":1949,"children":1950},{},[1951],{"type":38,"value":1952},"Write-Behind (Asincrónico):",{"type":38,"value":1954},"\nEscribe en DB, devuelve respuesta, un job de fondo actualiza KV. Latencia de escritura 50-80ms, pero riesgo de 100-200ms de anterioridad en KV.",{"type":33,"tag":74,"props":1956,"children":1958},{"className":76,"code":1957,"language":78,"meta":17,"style":17},"app.post('\u002Fcart\u002Fadd', async (req, res) => {\n  const { userId, productId } = req.body;\n  \n  await db.query('INSERT INTO cart_items ...');\n  \n  \u002F\u002F Delega actualización de KV a job asincrónico\n  queueKVUpdate('user', userId);\n  \n  res.json({ success: true });\n});\n\nasync function queueKVUpdate(type, id) {\n  \u002F\u002F Cola Redis o Cloudflare Durable Objects\n  await redis.lpush('kv_updates', JSON.stringify({ type, id }));\n}\n",[1959],{"type":33,"tag":81,"props":1960,"children":1961},{"__ignoreMap":17},[1962,2017,2052,2059,2086,2093,2101,2123,2130,2153,2160,2167,2205,2213,2260],{"type":33,"tag":85,"props":1963,"children":1964},{"class":87,"line":88},[1965,1969,1973,1977,1981,1985,1989,1993,1997,2001,2005,2009,2013],{"type":33,"tag":85,"props":1966,"children":1967},{"style":113},[1968],{"type":38,"value":1647},{"type":33,"tag":85,"props":1970,"children":1971},{"style":128},[1972],{"type":38,"value":1652},{"type":33,"tag":85,"props":1974,"children":1975},{"style":113},[1976],{"type":38,"value":136},{"type":33,"tag":85,"props":1978,"children":1979},{"style":292},[1980],{"type":38,"value":1661},{"type":33,"tag":85,"props":1982,"children":1983},{"style":113},[1984],{"type":38,"value":147},{"type":33,"tag":85,"props":1986,"children":1987},{"style":102},[1988],{"type":38,"value":1670},{"type":33,"tag":85,"props":1990,"children":1991},{"style":113},[1992],{"type":38,"value":342},{"type":33,"tag":85,"props":1994,"children":1995},{"style":139},[1996],{"type":38,"value":1060},{"type":33,"tag":85,"props":1998,"children":1999},{"style":113},[2000],{"type":38,"value":147},{"type":33,"tag":85,"props":2002,"children":2003},{"style":139},[2004],{"type":38,"value":1687},{"type":33,"tag":85,"props":2006,"children":2007},{"style":113},[2008],{"type":38,"value":1692},{"type":33,"tag":85,"props":2010,"children":2011},{"style":102},[2012],{"type":38,"value":1697},{"type":33,"tag":85,"props":2014,"children":2015},{"style":113},[2016],{"type":38,"value":116},{"type":33,"tag":85,"props":2018,"children":2019},{"class":87,"line":98},[2020,2024,2028,2032,2036,2040,2044,2048],{"type":33,"tag":85,"props":2021,"children":2022},{"style":102},[2023],{"type":38,"value":1082},{"type":33,"tag":85,"props":2025,"children":2026},{"style":113},[2027],{"type":38,"value":1713},{"type":33,"tag":85,"props":2029,"children":2030},{"style":169},[2031],{"type":38,"value":300},{"type":33,"tag":85,"props":2033,"children":2034},{"style":113},[2035],{"type":38,"value":147},{"type":33,"tag":85,"props":2037,"children":2038},{"style":169},[2039],{"type":38,"value":1726},{"type":33,"tag":85,"props":2041,"children":2042},{"style":113},[2043],{"type":38,"value":1731},{"type":33,"tag":85,"props":2045,"children":2046},{"style":102},[2047],{"type":38,"value":1736},{"type":33,"tag":85,"props":2049,"children":2050},{"style":113},[2051],{"type":38,"value":1741},{"type":33,"tag":85,"props":2053,"children":2054},{"class":87,"line":119},[2055],{"type":33,"tag":85,"props":2056,"children":2057},{"style":113},[2058],{"type":38,"value":1121},{"type":33,"tag":85,"props":2060,"children":2061},{"class":87,"line":160},[2062,2066,2070,2074,2078,2082],{"type":33,"tag":85,"props":2063,"children":2064},{"style":102},[2065],{"type":38,"value":1764},{"type":33,"tag":85,"props":2067,"children":2068},{"style":113},[2069],{"type":38,"value":1769},{"type":33,"tag":85,"props":2071,"children":2072},{"style":128},[2073],{"type":38,"value":1774},{"type":33,"tag":85,"props":2075,"children":2076},{"style":113},[2077],{"type":38,"value":136},{"type":33,"tag":85,"props":2079,"children":2080},{"style":292},[2081],{"type":38,"value":1783},{"type":33,"tag":85,"props":2083,"children":2084},{"style":113},[2085],{"type":38,"value":1254},{"type":33,"tag":85,"props":2087,"children":2088},{"class":87,"line":195},[2089],{"type":33,"tag":85,"props":2090,"children":2091},{"style":113},[2092],{"type":38,"value":1121},{"type":33,"tag":85,"props":2094,"children":2095},{"class":87,"line":227},[2096],{"type":33,"tag":85,"props":2097,"children":2098},{"style":92},[2099],{"type":38,"value":2100},"  \u002F\u002F Delega actualización de KV a job asincrónico\n",{"type":33,"tag":85,"props":2102,"children":2103},{"class":87,"line":237},[2104,2109,2113,2118],{"type":33,"tag":85,"props":2105,"children":2106},{"style":128},[2107],{"type":38,"value":2108},"  queueKVUpdate",{"type":33,"tag":85,"props":2110,"children":2111},{"style":113},[2112],{"type":38,"value":136},{"type":33,"tag":85,"props":2114,"children":2115},{"style":292},[2116],{"type":38,"value":2117},"'user'",{"type":33,"tag":85,"props":2119,"children":2120},{"style":113},[2121],{"type":38,"value":2122},", userId);\n",{"type":33,"tag":85,"props":2124,"children":2125},{"class":87,"line":246},[2126],{"type":33,"tag":85,"props":2127,"children":2128},{"style":113},[2129],{"type":38,"value":1121},{"type":33,"tag":85,"props":2131,"children":2132},{"class":87,"line":27},[2133,2137,2141,2145,2149],{"type":33,"tag":85,"props":2134,"children":2135},{"style":113},[2136],{"type":38,"value":1918},{"type":33,"tag":85,"props":2138,"children":2139},{"style":128},[2140],{"type":38,"value":1284},{"type":33,"tag":85,"props":2142,"children":2143},{"style":113},[2144],{"type":38,"value":1927},{"type":33,"tag":85,"props":2146,"children":2147},{"style":169},[2148],{"type":38,"value":1932},{"type":33,"tag":85,"props":2150,"children":2151},{"style":113},[2152],{"type":38,"value":320},{"type":33,"tag":85,"props":2154,"children":2155},{"class":87,"line":331},[2156],{"type":33,"tag":85,"props":2157,"children":2158},{"style":113},[2159],{"type":38,"value":1944},{"type":33,"tag":85,"props":2161,"children":2162},{"class":87,"line":355},[2163],{"type":33,"tag":85,"props":2164,"children":2165},{"emptyLinePlaceholder":231},[2166],{"type":38,"value":234},{"type":33,"tag":85,"props":2168,"children":2169},{"class":87,"line":396},[2170,2174,2178,2183,2187,2192,2196,2201],{"type":33,"tag":85,"props":2171,"children":2172},{"style":102},[2173],{"type":38,"value":1670},{"type":33,"tag":85,"props":2175,"children":2176},{"style":102},[2177],{"type":38,"value":1046},{"type":33,"tag":85,"props":2179,"children":2180},{"style":128},[2181],{"type":38,"value":2182}," queueKVUpdate",{"type":33,"tag":85,"props":2184,"children":2185},{"style":113},[2186],{"type":38,"value":136},{"type":33,"tag":85,"props":2188,"children":2189},{"style":139},[2190],{"type":38,"value":2191},"type",{"type":33,"tag":85,"props":2193,"children":2194},{"style":113},[2195],{"type":38,"value":147},{"type":33,"tag":85,"props":2197,"children":2198},{"style":139},[2199],{"type":38,"value":2200},"id",{"type":33,"tag":85,"props":2202,"children":2203},{"style":113},[2204],{"type":38,"value":157},{"type":33,"tag":85,"props":2206,"children":2207},{"class":87,"line":405},[2208],{"type":33,"tag":85,"props":2209,"children":2210},{"style":92},[2211],{"type":38,"value":2212},"  \u002F\u002F Cola Redis o Cloudflare Durable Objects\n",{"type":33,"tag":85,"props":2214,"children":2215},{"class":87,"line":413},[2216,2220,2225,2230,2234,2239,2243,2247,2251,2255],{"type":33,"tag":85,"props":2217,"children":2218},{"style":102},[2219],{"type":38,"value":1764},{"type":33,"tag":85,"props":2221,"children":2222},{"style":113},[2223],{"type":38,"value":2224}," redis.",{"type":33,"tag":85,"props":2226,"children":2227},{"style":128},[2228],{"type":38,"value":2229},"lpush",{"type":33,"tag":85,"props":2231,"children":2232},{"style":113},[2233],{"type":38,"value":136},{"type":33,"tag":85,"props":2235,"children":2236},{"style":292},[2237],{"type":38,"value":2238},"'kv_updates'",{"type":33,"tag":85,"props":2240,"children":2241},{"style":113},[2242],{"type":38,"value":147},{"type":33,"tag":85,"props":2244,"children":2245},{"style":169},[2246],{"type":38,"value":1364},{"type":33,"tag":85,"props":2248,"children":2249},{"style":113},[2250],{"type":38,"value":280},{"type":33,"tag":85,"props":2252,"children":2253},{"style":128},[2254],{"type":38,"value":1373},{"type":33,"tag":85,"props":2256,"children":2257},{"style":113},[2258],{"type":38,"value":2259},"({ type, id }));\n",{"type":33,"tag":85,"props":2261,"children":2262},{"class":87,"line":422},[2263],{"type":33,"tag":85,"props":2264,"children":2265},{"style":113},[2266],{"type":38,"value":871},{"type":33,"tag":34,"props":2268,"children":2269},{},[2270],{"type":38,"value":2271},"Para e-commerce, write-behind tiene sentido al agregar al carrito — el usuario no nota 100ms, y en checkout se hace double-check con origen. Para datos críticos como cambios de precio, write-through es preferible.",{"type":33,"tag":41,"props":2273,"children":2275},{"id":2274},"capa-de-caché-híbrida-estática-edge-ssr",[2276],{"type":38,"value":2277},"Capa de Caché Híbrida: Estática + Edge SSR",{"type":33,"tag":34,"props":2279,"children":2280},{},[2281,2283,2292],{"type":38,"value":2282},"Mejor que solo Edge SSR es una arquitectura estática + dinámico híbrida. Ejemplo: en proyectos ",{"type":33,"tag":2284,"props":2285,"children":2289},"a",{"href":2286,"rel":2287},"https:\u002F\u002Fwww.roibase.com.tr\u002Fes\u002Fheadless",[2288],"nofollow",[2290],{"type":38,"value":2291},"Headless Commerce",{"type":38,"value":2293}," de Roibase, generamos estáticamente el esqueleto de la página de inicio (header, footer, lista general de categorías) e inyectamos bloques específicos del usuario (icono del carrito, nombre del usuario, widget de recomendaciones) en edge. Este enfoque lleva el hit rate de caché a 92%.",{"type":33,"tag":34,"props":2295,"children":2296},{},[2297],{"type":38,"value":2298},"Con Next.js:",{"type":33,"tag":74,"props":2300,"children":2302},{"className":981,"code":2301,"language":983,"meta":17,"style":17},"\u002F\u002F app\u002Fpage.tsx — Layout estático\nexport default function HomePage() {\n  return (\n    \u003Cmain>\n      \u003CHeader \u002F> {\u002F* Estático *\u002F}\n      \u003CHeroSection \u002F> {\u002F* Estático *\u002F}\n      \u003CUserWidget \u002F> {\u002F* Edge SSR *\u002F}\n      \u003CProductGrid \u002F> {\u002F* ISR estático, revalidar cada 60s *\u002F}\n    \u003C\u002Fmain>\n  );\n}\n\n\u002F\u002F components\u002FUserWidget.tsx — Server component, runtime edge\nexport const runtime = 'edge';\n\nexport default async function UserWidget() {\n  const userId = cookies().get('userId')?.value;\n  const userCtx = await fetch(`https:\u002F\u002Fkv...\u002Fuser:${userId}`);\n  const data = await userCtx.json();\n\n  return \u003Cdiv>Bienvenido {data.name}\u003C\u002Fdiv>;\n}\n",[2303],{"type":33,"tag":81,"props":2304,"children":2305},{"__ignoreMap":17},[2306,2314,2339,2351,2369,2401,2429,2458,2487,2503,2511,2518,2525,2533,2562,2569,2597,2638,2682,2713,2720,2760],{"type":33,"tag":85,"props":2307,"children":2308},{"class":87,"line":88},[2309],{"type":33,"tag":85,"props":2310,"children":2311},{"style":92},[2312],{"type":38,"value":2313},"\u002F\u002F app\u002Fpage.tsx — Layout estático\n",{"type":33,"tag":85,"props":2315,"children":2316},{"class":87,"line":98},[2317,2321,2325,2329,2334],{"type":33,"tag":85,"props":2318,"children":2319},{"style":102},[2320],{"type":38,"value":105},{"type":33,"tag":85,"props":2322,"children":2323},{"style":102},[2324],{"type":38,"value":110},{"type":33,"tag":85,"props":2326,"children":2327},{"style":102},[2328],{"type":38,"value":1046},{"type":33,"tag":85,"props":2330,"children":2331},{"style":128},[2332],{"type":38,"value":2333}," HomePage",{"type":33,"tag":85,"props":2335,"children":2336},{"style":113},[2337],{"type":38,"value":2338},"() {\n",{"type":33,"tag":85,"props":2340,"children":2341},{"class":87,"line":119},[2342,2346],{"type":33,"tag":85,"props":2343,"children":2344},{"style":102},[2345],{"type":38,"value":654},{"type":33,"tag":85,"props":2347,"children":2348},{"style":113},[2349],{"type":38,"value":2350}," (\n",{"type":33,"tag":85,"props":2352,"children":2353},{"class":87,"line":160},[2354,2359,2364],{"type":33,"tag":85,"props":2355,"children":2356},{"style":113},[2357],{"type":38,"value":2358},"    \u003C",{"type":33,"tag":85,"props":2360,"children":2361},{"style":128},[2362],{"type":38,"value":2363},"main",{"type":33,"tag":85,"props":2365,"children":2366},{"style":113},[2367],{"type":38,"value":2368},">\n",{"type":33,"tag":85,"props":2370,"children":2371},{"class":87,"line":195},[2372,2377,2382,2387,2392,2397],{"type":33,"tag":85,"props":2373,"children":2374},{"style":102},[2375],{"type":38,"value":2376},"      \u003C",{"type":33,"tag":85,"props":2378,"children":2379},{"style":113},[2380],{"type":38,"value":2381},"Header ",{"type":33,"tag":85,"props":2383,"children":2384},{"style":102},[2385],{"type":38,"value":2386},"\u002F>",{"type":33,"tag":85,"props":2388,"children":2389},{"style":113},[2390],{"type":38,"value":2391}," {",{"type":33,"tag":85,"props":2393,"children":2394},{"style":92},[2395],{"type":38,"value":2396},"\u002F* Estático *\u002F",{"type":33,"tag":85,"props":2398,"children":2399},{"style":113},[2400],{"type":38,"value":871},{"type":33,"tag":85,"props":2402,"children":2403},{"class":87,"line":227},[2404,2408,2413,2417,2421,2425],{"type":33,"tag":85,"props":2405,"children":2406},{"style":102},[2407],{"type":38,"value":2376},{"type":33,"tag":85,"props":2409,"children":2410},{"style":113},[2411],{"type":38,"value":2412},"HeroSection ",{"type":33,"tag":85,"props":2414,"children":2415},{"style":102},[2416],{"type":38,"value":2386},{"type":33,"tag":85,"props":2418,"children":2419},{"style":113},[2420],{"type":38,"value":2391},{"type":33,"tag":85,"props":2422,"children":2423},{"style":92},[2424],{"type":38,"value":2396},{"type":33,"tag":85,"props":2426,"children":2427},{"style":113},[2428],{"type":38,"value":871},{"type":33,"tag":85,"props":2430,"children":2431},{"class":87,"line":237},[2432,2436,2441,2445,2449,2454],{"type":33,"tag":85,"props":2433,"children":2434},{"style":102},[2435],{"type":38,"value":2376},{"type":33,"tag":85,"props":2437,"children":2438},{"style":113},[2439],{"type":38,"value":2440},"UserWidget ",{"type":33,"tag":85,"props":2442,"children":2443},{"style":102},[2444],{"type":38,"value":2386},{"type":33,"tag":85,"props":2446,"children":2447},{"style":113},[2448],{"type":38,"value":2391},{"type":33,"tag":85,"props":2450,"children":2451},{"style":92},[2452],{"type":38,"value":2453},"\u002F* Edge SSR *\u002F",{"type":33,"tag":85,"props":2455,"children":2456},{"style":113},[2457],{"type":38,"value":871},{"type":33,"tag":85,"props":2459,"children":2460},{"class":87,"line":246},[2461,2465,2470,2474,2478,2483],{"type":33,"tag":85,"props":2462,"children":2463},{"style":102},[2464],{"type":38,"value":2376},{"type":33,"tag":85,"props":2466,"children":2467},{"style":113},[2468],{"type":38,"value":2469},"ProductGrid ",{"type":33,"tag":85,"props":2471,"children":2472},{"style":102},[2473],{"type":38,"value":2386},{"type":33,"tag":85,"props":2475,"children":2476},{"style":113},[2477],{"type":38,"value":2391},{"type":33,"tag":85,"props":2479,"children":2480},{"style":92},[2481],{"type":38,"value":2482},"\u002F* ISR estático, revalidar cada 60s *\u002F",{"type":33,"tag":85,"props":2484,"children":2485},{"style":113},[2486],{"type":38,"value":871},{"type":33,"tag":85,"props":2488,"children":2489},{"class":87,"line":27},[2490,2495,2499],{"type":33,"tag":85,"props":2491,"children":2492},{"style":102},[2493],{"type":38,"value":2494},"    \u003C\u002F",{"type":33,"tag":85,"props":2496,"children":2497},{"style":113},[2498],{"type":38,"value":2363},{"type":33,"tag":85,"props":2500,"children":2501},{"style":102},[2502],{"type":38,"value":2368},{"type":33,"tag":85,"props":2504,"children":2505},{"class":87,"line":331},[2506],{"type":33,"tag":85,"props":2507,"children":2508},{"style":113},[2509],{"type":38,"value":2510},"  );\n",{"type":33,"tag":85,"props":2512,"children":2513},{"class":87,"line":355},[2514],{"type":33,"tag":85,"props":2515,"children":2516},{"style":113},[2517],{"type":38,"value":871},{"type":33,"tag":85,"props":2519,"children":2520},{"class":87,"line":396},[2521],{"type":33,"tag":85,"props":2522,"children":2523},{"emptyLinePlaceholder":231},[2524],{"type":38,"value":234},{"type":33,"tag":85,"props":2526,"children":2527},{"class":87,"line":405},[2528],{"type":33,"tag":85,"props":2529,"children":2530},{"style":92},[2531],{"type":38,"value":2532},"\u002F\u002F components\u002FUserWidget.tsx — Server component, runtime edge\n",{"type":33,"tag":85,"props":2534,"children":2535},{"class":87,"line":413},[2536,2540,2544,2549,2553,2558],{"type":33,"tag":85,"props":2537,"children":2538},{"style":102},[2539],{"type":38,"value":105},{"type":33,"tag":85,"props":2541,"children":2542},{"style":102},[2543],{"type":38,"value":1423},{"type":33,"tag":85,"props":2545,"children":2546},{"style":169},[2547],{"type":38,"value":2548}," runtime",{"type":33,"tag":85,"props":2550,"children":2551},{"style":102},[2552],{"type":38,"value":177},{"type":33,"tag":85,"props":2554,"children":2555},{"style":292},[2556],{"type":38,"value":2557}," 'edge'",{"type":33,"tag":85,"props":2559,"children":2560},{"style":113},[2561],{"type":38,"value":912},{"type":33,"tag":85,"props":2563,"children":2564},{"class":87,"line":422},[2565],{"type":33,"tag":85,"props":2566,"children":2567},{"emptyLinePlaceholder":231},[2568],{"type":38,"value":234},{"type":33,"tag":85,"props":2570,"children":2571},{"class":87,"line":449},[2572,2576,2580,2584,2588,2593],{"type":33,"tag":85,"props":2573,"children":2574},{"style":102},[2575],{"type":38,"value":105},{"type":33,"tag":85,"props":2577,"children":2578},{"style":102},[2579],{"type":38,"value":110},{"type":33,"tag":85,"props":2581,"children":2582},{"style":102},[2583],{"type":38,"value":1041},{"type":33,"tag":85,"props":2585,"children":2586},{"style":102},[2587],{"type":38,"value":1046},{"type":33,"tag":85,"props":2589,"children":2590},{"style":128},[2591],{"type":38,"value":2592}," UserWidget",{"type":33,"tag":85,"props":2594,"children":2595},{"style":113},[2596],{"type":38,"value":2338},{"type":33,"tag":85,"props":2598,"children":2599},{"class":87,"line":458},[2600,2604,2608,2612,2617,2622,2626,2630,2634],{"type":33,"tag":85,"props":2601,"children":2602},{"style":102},[2603],{"type":38,"value":1082},{"type":33,"tag":85,"props":2605,"children":2606},{"style":169},[2607],{"type":38,"value":205},{"type":33,"tag":85,"props":2609,"children":2610},{"style":102},[2611],{"type":38,"value":177},{"type":33,"tag":85,"props":2613,"children":2614},{"style":128},[2615],{"type":38,"value":2616}," cookies",{"type":33,"tag":85,"props":2618,"children":2619},{"style":113},[2620],{"type":38,"value":2621},"().",{"type":33,"tag":85,"props":2623,"children":2624},{"style":128},[2625],{"type":38,"value":285},{"type":33,"tag":85,"props":2627,"children":2628},{"style":113},[2629],{"type":38,"value":136},{"type":33,"tag":85,"props":2631,"children":2632},{"style":292},[2633],{"type":38,"value":1108},{"type":33,"tag":85,"props":2635,"children":2636},{"style":113},[2637],{"type":38,"value":1113},{"type":33,"tag":85,"props":2639,"children":2640},{"class":87,"line":467},[2641,2645,2649,2653,2657,2661,2665,2670,2674,2678],{"type":33,"tag":85,"props":2642,"children":2643},{"style":102},[2644],{"type":38,"value":1082},{"type":33,"tag":85,"props":2646,"children":2647},{"style":169},[2648],{"type":38,"value":256},{"type":33,"tag":85,"props":2650,"children":2651},{"style":102},[2652],{"type":38,"value":177},{"type":33,"tag":85,"props":2654,"children":2655},{"style":102},[2656],{"type":38,"value":265},{"type":33,"tag":85,"props":2658,"children":2659},{"style":128},[2660],{"type":38,"value":131},{"type":33,"tag":85,"props":2662,"children":2663},{"style":113},[2664],{"type":38,"value":136},{"type":33,"tag":85,"props":2666,"children":2667},{"style":292},[2668],{"type":38,"value":2669},"`https:\u002F\u002Fkv...\u002Fuser:${",{"type":33,"tag":85,"props":2671,"children":2672},{"style":113},[2673],{"type":38,"value":300},{"type":33,"tag":85,"props":2675,"children":2676},{"style":292},[2677],{"type":38,"value":305},{"type":33,"tag":85,"props":2679,"children":2680},{"style":113},[2681],{"type":38,"value":1254},{"type":33,"tag":85,"props":2683,"children":2684},{"class":87,"line":476},[2685,2689,2693,2697,2701,2705,2709],{"type":33,"tag":85,"props":2686,"children":2687},{"style":102},[2688],{"type":38,"value":1082},{"type":33,"tag":85,"props":2690,"children":2691},{"style":169},[2692],{"type":38,"value":1266},{"type":33,"tag":85,"props":2694,"children":2695},{"style":102},[2696],{"type":38,"value":177},{"type":33,"tag":85,"props":2698,"children":2699},{"style":102},[2700],{"type":38,"value":265},{"type":33,"tag":85,"props":2702,"children":2703},{"style":113},[2704],{"type":38,"value":1279},{"type":33,"tag":85,"props":2706,"children":2707},{"style":128},[2708],{"type":38,"value":1284},{"type":33,"tag":85,"props":2710,"children":2711},{"style":113},[2712],{"type":38,"value":1289},{"type":33,"tag":85,"props":2714,"children":2715},{"class":87,"line":485},[2716],{"type":33,"tag":85,"props":2717,"children":2718},{"emptyLinePlaceholder":231},[2719],{"type":38,"value":234},{"type":33,"tag":85,"props":2721,"children":2722},{"class":87,"line":493},[2723,2727,2732,2737,2742,2747,2751,2756],{"type":33,"tag":85,"props":2724,"children":2725},{"style":102},[2726],{"type":38,"value":654},{"type":33,"tag":85,"props":2728,"children":2729},{"style":113},[2730],{"type":38,"value":2731}," \u003C",{"type":33,"tag":85,"props":2733,"children":2734},{"style":128},[2735],{"type":38,"value":2736},"div",{"type":33,"tag":85,"props":2738,"children":2739},{"style":113},[2740],{"type":38,"value":2741},">Bienvenido {data.name}",{"type":33,"tag":85,"props":2743,"children":2744},{"style":102},[2745],{"type":38,"value":2746},"\u003C\u002F",{"type":33,"tag":85,"props":2748,"children":2749},{"style":113},[2750],{"type":38,"value":2736},{"type":33,"tag":85,"props":2752,"children":2753},{"style":102},[2754],{"type":38,"value":2755},">",{"type":33,"tag":85,"props":2757,"children":2758},{"style":113},[2759],{"type":38,"value":912},{"type":33,"tag":85,"props":2761,"children":2762},{"class":87,"line":515},[2763],{"type":33,"tag":85,"props":2764,"children":2765},{"style":113},[2766],{"type":38,"value":871},{"type":33,"tag":34,"props":2768,"children":2769},{},[2770],{"type":38,"value":2771},"Con este setup, el 80% del HTML se sirve estáticamente desde CDN (TTFB 8-12ms), el 20% se renderiza en edge (30-40ms adicionales). TTFB total 40-50ms. La misma página con full SSR basado en origen tardaba 180-220ms.",{"type":33,"tag":34,"props":2773,"children":2774},{},[2775,2780],{"type":33,"tag":925,"props":2776,"children":2777},{},[2778],{"type":38,"value":2779},"Mejora con Streaming SSR:",{"type":38,"value":2781}," Con Suspense de React 18, devuelves la parte estática inmediatamente, streameas la parte edge SSR. El navegador comienza a parsear HTML, el usuario ve contenido a los 20ms, el widget personalizado llega 30ms después con \"hydration\". La latencia percibida cae a 20ms.",{"type":33,"tag":41,"props":2783,"children":2785},{"id":2784},"escenario-de-producción-cómo-se-logró-40ms",[2786],{"type":38,"value":2787},"Escenario de Producción: Cómo Se Logró 40ms",{"type":33,"tag":34,"props":2789,"children":2790},{},[2791],{"type":38,"value":2792},"Caso real: sitio de e-commerce basado en Shopify Hydrogen, Cloudflare Workers + KV. Latencia inicial 210ms (origen en Fráncfort, usuario en Estambul), objetivo \u003C50ms.",{"type":33,"tag":34,"props":2794,"children":2795},{},[2796],{"type":33,"tag":925,"props":2797,"children":2798},{},[2799],{"type":38,"value":2800},"Optimizaciones aplicadas:",{"type":33,"tag":2802,"props":2803,"children":2804},"ol",{},[2805,2822,2847,2857],{"type":33,"tag":935,"props":2806,"children":2807},{},[2808,2813,2815,2821],{"type":33,"tag":925,"props":2809,"children":2810},{},[2811],{"type":38,"value":2812},"Reducción de tamaño de datos KV:",{"type":38,"value":2814}," Redujimos el contexto de usuario de 2.4KB a 800 bytes — solo campos críticos (userId, cart, priceTier). Ürünleri recientemente vistos se movieron a clave separada (",{"type":33,"tag":81,"props":2816,"children":2818},{"className":2817},[],[2819],{"type":38,"value":2820},"user:{id}:recent",{"type":38,"value":847},{"type":33,"tag":935,"props":2823,"children":2824},{},[2825,2830,2832,2837,2839,2845],{"type":33,"tag":925,"props":2826,"children":2827},{},[2828],{"type":38,"value":2829},"Reducción de bundle:",{"type":38,"value":2831}," Reemplazamos React con Preact (3KB), ",{"type":33,"tag":81,"props":2833,"children":2835},{"className":2834},[],[2836],{"type":38,"value":1507},{"type":38,"value":2838}," con ",{"type":33,"tag":81,"props":2840,"children":2842},{"className":2841},[],[2843],{"type":38,"value":2844},"Intl.DateTimeFormat",{"type":38,"value":2846}," nativo. El bundle del worker bajó de 180KB a 65KB.",{"type":33,"tag":935,"props":2848,"children":2849},{},[2850,2855],{"type":33,"tag":925,"props":2851,"children":2852},{},[2853],{"type":38,"value":2854},"Caché híbrido:",{"type":38,"value":2856}," Página de inicio estática (cache CDN 300s), solo botón \"Agregar al Carrito\" y precios en Edge SSR. Hit rate de caché pasó de 88% a 94%.",{"type":33,"tag":935,"props":2858,"children":2859},{},[2860,2865],{"type":33,"tag":925,"props":2861,"children":2862},{},[2863],{"type":38,"value":2864},"Selección de PoP edge:",{"type":38,"value":2866}," Activamos \"Smart Routing\" de Cloudflare — sirve desde el PoP con latencia más baja. El usuario en Estambul se dirige a PoP de Sofía (RTT 22ms), no a Fráncfort.",{"type":33,"tag":34,"props":2868,"children":2869},{},[2870,2875],{"type":33,"tag":925,"props":2871,"children":2872},{},[2873],{"type":38,"value":2874},"Resultado:",{"type":38,"value":2876}," TTFB 210ms → 42ms (mediana), LCP 2.1s → 0.9s, INP 180ms → 95ms. La tasa de conversión subió de 2.3% a 2.9% (+26% lift). El costo mensual del servidor de origen bajó de $340 a $95 (costo edge $28\u002Fmes).",{"type":33,"tag":34,"props":2878,"children":2879},{},[2880],{"type":38,"value":2881},"El auge de Edge SSR se acelera en 2026 — Cloudflare, Vercel, Fastly prometen latencia sub-50ms. Con arquitectura KV store bien diseñada, la personalización se maneja sin ir al origen. Hay tradeoffs: límite de tamaño de bundle, debugging más difícil, riesgo de consistencia eventual. Pero en escenarios correctos (e-commerce, dashboard, SaaS), la ganancia es clara. Los 40ms de latencia ya no son lujo, son estándar.",{"type":33,"tag":2883,"props":2884,"children":2885},"style",{},[2886],{"type":38,"value":2887},"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":17,"searchDepth":119,"depth":119,"links":2889},[2890,2891,2894,2895,2896,2897],{"id":43,"depth":98,"text":46},{"id":64,"depth":98,"text":67,"children":2892},[2893],{"id":970,"depth":119,"text":973},{"id":1478,"depth":98,"text":1481},{"id":1606,"depth":98,"text":1609},{"id":2274,"depth":98,"text":2277},{"id":2784,"depth":98,"text":2787},"markdown","content:es:tech:edge-ssr-40ms-latency.md","content","es\u002Ftech\u002Fedge-ssr-40ms-latency.md","es\u002Ftech\u002Fedge-ssr-40ms-latency","md",1785967481623]