[{"data":1,"prerenderedAt":1905},["ShallowReactive",2],{"article-alternates":3,"article-\u002Fit\u002Ftech\u002Fssg-strategie-nuxt-3-prerender-e-ottimizzazione-build":13},{"i18nKey":4,"paths":5},"tech-007-2026-08",{"de":6,"en":7,"es":8,"fr":9,"it":10,"ru":11,"tr":12},"\u002Fde\u002Ftech\u002Fssg-leitfaden-fuer-nuxt-3","\u002Fen\u002Ftech\u002Fnuxt-3-ssg-prerender-strategies-build-optimization","\u002Fes\u002Ftech\u002Festrategias-prerender-ssg-nuxt-3","\u002Ffr\u002Ftech\u002Fstrategie-prerender-nuxt-3","\u002Fit\u002Ftech\u002Fssg-strategie-nuxt-3-prerender-e-ottimizzazione-build","\u002Fru\u002Ftech\u002Fssg-strategii-dlya-nuxt-3-i-optimizaciya-sborki","\u002Ftr\u002Ftech\u002Fnuxt-3-ssg-prerender-stratejileri-ve-build-optimizasyonu",{"_path":10,"_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":1899,"_id":1900,"_source":1901,"_file":1902,"_stem":1903,"_extension":1904},"tech",false,"","Nuxt 3 SSG: Strategie di Prerender e Ottimizzazione Build","Static site generation in Nuxt 3: route rules, prerendering Nitro, build incrementali e strategie di deployment in produzione.","2026-08-06",[21,22,23,24,25],"nuxt-3","ssg","static-generation","web-performance","nitro",8,"Roibase",{"type":29,"children":30,"toc":1886},"root",[31,39,46,68,229,250,257,270,510,523,529,553,707,712,769,775,788,843,855,861,874,1148,1168,1174,1179,1400,1405,1411,1423,1665,1670,1698,1703,1709,1722,1864,1875,1880],{"type":32,"tag":33,"props":34,"children":35},"element","p",{},[36],{"type":37,"value":38},"text","L'architettura SSG (Static Site Generation) di Nuxt 3 segna una rottura sostanziale rispetto al comando \"nuxt generate\" dell'era Vue 2. Il nuovo sistema di prerender basato su Nitro offre granularità a livello di route — puoi definire una strategia di rendering diversa per ogni pagina. In questo articolo affrontiamo la configurazione SSG pronta per la produzione, la configurazione di rendering ibrido con route rules e i colli di bottiglia di prestazioni che incontri frequentemente nella pipeline di build.",{"type":32,"tag":40,"props":41,"children":43},"h2",{"id":42},"prerendering-nitro-la-nuova-base-dellssg",[44],{"type":37,"value":45},"Prerendering Nitro: La Nuova Base dell'SSG",{"type":32,"tag":33,"props":47,"children":48},{},[49,51,58,60,66],{"type":37,"value":50},"In Nuxt 3, l'SSG funziona attraverso il motore di prerendering di Nitro. Lo controlli con la chiave ",{"type":32,"tag":52,"props":53,"children":55},"code",{"className":54},[],[56],{"type":37,"value":57},"nitro.prerender",{"type":37,"value":59}," nel file ",{"type":32,"tag":52,"props":61,"children":63},{"className":62},[],[64],{"type":37,"value":65},"nuxt.config.ts",{"type":37,"value":67},". L'approccio classico era rendere tutte le route in fase di build — ora il prerendering selettivo è possibile.",{"type":32,"tag":69,"props":70,"children":74},"pre",{"className":71,"code":72,"language":73,"meta":16,"style":16},"language-typescript shiki shiki-themes github-dark","export default defineNuxtConfig({\n  nitro: {\n    prerender: {\n      crawlLinks: true,\n      routes: ['\u002Fsitemap.xml', '\u002Frss.xml'],\n      ignore: ['\u002Fapi', '\u002Fadmin']\n    }\n  }\n})\n","typescript",[75],{"type":32,"tag":52,"props":76,"children":77},{"__ignoreMap":16},[78,107,116,125,145,175,203,212,220],{"type":32,"tag":79,"props":80,"children":83},"span",{"class":81,"line":82},"line",1,[84,90,95,101],{"type":32,"tag":79,"props":85,"children":87},{"style":86},"--shiki-default:#F97583",[88],{"type":37,"value":89},"export",{"type":32,"tag":79,"props":91,"children":92},{"style":86},[93],{"type":37,"value":94}," default",{"type":32,"tag":79,"props":96,"children":98},{"style":97},"--shiki-default:#B392F0",[99],{"type":37,"value":100}," defineNuxtConfig",{"type":32,"tag":79,"props":102,"children":104},{"style":103},"--shiki-default:#E1E4E8",[105],{"type":37,"value":106},"({\n",{"type":32,"tag":79,"props":108,"children":110},{"class":81,"line":109},2,[111],{"type":32,"tag":79,"props":112,"children":113},{"style":103},[114],{"type":37,"value":115},"  nitro: {\n",{"type":32,"tag":79,"props":117,"children":119},{"class":81,"line":118},3,[120],{"type":32,"tag":79,"props":121,"children":122},{"style":103},[123],{"type":37,"value":124},"    prerender: {\n",{"type":32,"tag":79,"props":126,"children":128},{"class":81,"line":127},4,[129,134,140],{"type":32,"tag":79,"props":130,"children":131},{"style":103},[132],{"type":37,"value":133},"      crawlLinks: ",{"type":32,"tag":79,"props":135,"children":137},{"style":136},"--shiki-default:#79B8FF",[138],{"type":37,"value":139},"true",{"type":32,"tag":79,"props":141,"children":142},{"style":103},[143],{"type":37,"value":144},",\n",{"type":32,"tag":79,"props":146,"children":148},{"class":81,"line":147},5,[149,154,160,165,170],{"type":32,"tag":79,"props":150,"children":151},{"style":103},[152],{"type":37,"value":153},"      routes: [",{"type":32,"tag":79,"props":155,"children":157},{"style":156},"--shiki-default:#9ECBFF",[158],{"type":37,"value":159},"'\u002Fsitemap.xml'",{"type":32,"tag":79,"props":161,"children":162},{"style":103},[163],{"type":37,"value":164},", ",{"type":32,"tag":79,"props":166,"children":167},{"style":156},[168],{"type":37,"value":169},"'\u002Frss.xml'",{"type":32,"tag":79,"props":171,"children":172},{"style":103},[173],{"type":37,"value":174},"],\n",{"type":32,"tag":79,"props":176,"children":178},{"class":81,"line":177},6,[179,184,189,193,198],{"type":32,"tag":79,"props":180,"children":181},{"style":103},[182],{"type":37,"value":183},"      ignore: [",{"type":32,"tag":79,"props":185,"children":186},{"style":156},[187],{"type":37,"value":188},"'\u002Fapi'",{"type":32,"tag":79,"props":190,"children":191},{"style":103},[192],{"type":37,"value":164},{"type":32,"tag":79,"props":194,"children":195},{"style":156},[196],{"type":37,"value":197},"'\u002Fadmin'",{"type":32,"tag":79,"props":199,"children":200},{"style":103},[201],{"type":37,"value":202},"]\n",{"type":32,"tag":79,"props":204,"children":206},{"class":81,"line":205},7,[207],{"type":32,"tag":79,"props":208,"children":209},{"style":103},[210],{"type":37,"value":211},"    }\n",{"type":32,"tag":79,"props":213,"children":214},{"class":81,"line":26},[215],{"type":32,"tag":79,"props":216,"children":217},{"style":103},[218],{"type":37,"value":219},"  }\n",{"type":32,"tag":79,"props":221,"children":223},{"class":81,"line":222},9,[224],{"type":32,"tag":79,"props":225,"children":226},{"style":103},[227],{"type":37,"value":228},"})\n",{"type":32,"tag":33,"props":230,"children":231},{},[232,234,240,242,248],{"type":37,"value":233},"L'impostazione ",{"type":32,"tag":52,"props":235,"children":237},{"className":236},[],[238],{"type":37,"value":239},"crawlLinks: true",{"type":37,"value":241}," dice a Nuxt: scopri automaticamente e prerenderizza tutte le pagine collegate con ",{"type":32,"tag":52,"props":243,"children":245},{"className":244},[],[246],{"type":37,"value":247},"\u003CNuxtLink>",{"type":37,"value":249},". Questo funziona per i blog — ma su un sito di e-commerce con 10 mila prodotti il tempo di build esplode. Lì devi iniettare le route dinamicamente.",{"type":32,"tag":251,"props":252,"children":254},"h3",{"id":253},"iniezione-di-route-dinamiche",[255],{"type":37,"value":256},"Iniezione di Route Dinamiche",{"type":32,"tag":33,"props":258,"children":259},{},[260,262,268],{"type":37,"value":261},"Anziché fornire i percorsi manualmente all'array ",{"type":32,"tag":52,"props":263,"children":265},{"className":264},[],[266],{"type":37,"value":267},"routes",{"type":37,"value":269},", per le pagine di prodotto dinamiche usi i hook di Nitro:",{"type":32,"tag":69,"props":271,"children":273},{"className":71,"code":272,"language":73,"meta":16,"style":16},"\u002F\u002F server\u002Fplugins\u002Fprerender.ts\nexport default defineNitroPlugin((nitroApp) => {\n  nitroApp.hooks.hook('prerender:routes', async (ctx) => {\n    const products = await fetchProductSlugs() \u002F\u002F Estrai gli slug dall'API\n    products.forEach(slug => {\n      ctx.routes.add(`\u002Fproducts\u002F${slug}`)\n    })\n  })\n})\n",[274],{"type":32,"tag":52,"props":275,"children":276},{"__ignoreMap":16},[277,286,328,382,420,451,487,495,503],{"type":32,"tag":79,"props":278,"children":279},{"class":81,"line":82},[280],{"type":32,"tag":79,"props":281,"children":283},{"style":282},"--shiki-default:#6A737D",[284],{"type":37,"value":285},"\u002F\u002F server\u002Fplugins\u002Fprerender.ts\n",{"type":32,"tag":79,"props":287,"children":288},{"class":81,"line":109},[289,293,297,302,307,313,318,323],{"type":32,"tag":79,"props":290,"children":291},{"style":86},[292],{"type":37,"value":89},{"type":32,"tag":79,"props":294,"children":295},{"style":86},[296],{"type":37,"value":94},{"type":32,"tag":79,"props":298,"children":299},{"style":97},[300],{"type":37,"value":301}," defineNitroPlugin",{"type":32,"tag":79,"props":303,"children":304},{"style":103},[305],{"type":37,"value":306},"((",{"type":32,"tag":79,"props":308,"children":310},{"style":309},"--shiki-default:#FFAB70",[311],{"type":37,"value":312},"nitroApp",{"type":32,"tag":79,"props":314,"children":315},{"style":103},[316],{"type":37,"value":317},") ",{"type":32,"tag":79,"props":319,"children":320},{"style":86},[321],{"type":37,"value":322},"=>",{"type":32,"tag":79,"props":324,"children":325},{"style":103},[326],{"type":37,"value":327}," {\n",{"type":32,"tag":79,"props":329,"children":330},{"class":81,"line":118},[331,336,341,346,351,355,360,365,370,374,378],{"type":32,"tag":79,"props":332,"children":333},{"style":103},[334],{"type":37,"value":335},"  nitroApp.hooks.",{"type":32,"tag":79,"props":337,"children":338},{"style":97},[339],{"type":37,"value":340},"hook",{"type":32,"tag":79,"props":342,"children":343},{"style":103},[344],{"type":37,"value":345},"(",{"type":32,"tag":79,"props":347,"children":348},{"style":156},[349],{"type":37,"value":350},"'prerender:routes'",{"type":32,"tag":79,"props":352,"children":353},{"style":103},[354],{"type":37,"value":164},{"type":32,"tag":79,"props":356,"children":357},{"style":86},[358],{"type":37,"value":359},"async",{"type":32,"tag":79,"props":361,"children":362},{"style":103},[363],{"type":37,"value":364}," (",{"type":32,"tag":79,"props":366,"children":367},{"style":309},[368],{"type":37,"value":369},"ctx",{"type":32,"tag":79,"props":371,"children":372},{"style":103},[373],{"type":37,"value":317},{"type":32,"tag":79,"props":375,"children":376},{"style":86},[377],{"type":37,"value":322},{"type":32,"tag":79,"props":379,"children":380},{"style":103},[381],{"type":37,"value":327},{"type":32,"tag":79,"props":383,"children":384},{"class":81,"line":127},[385,390,395,400,405,410,415],{"type":32,"tag":79,"props":386,"children":387},{"style":86},[388],{"type":37,"value":389},"    const",{"type":32,"tag":79,"props":391,"children":392},{"style":136},[393],{"type":37,"value":394}," products",{"type":32,"tag":79,"props":396,"children":397},{"style":86},[398],{"type":37,"value":399}," =",{"type":32,"tag":79,"props":401,"children":402},{"style":86},[403],{"type":37,"value":404}," await",{"type":32,"tag":79,"props":406,"children":407},{"style":97},[408],{"type":37,"value":409}," fetchProductSlugs",{"type":32,"tag":79,"props":411,"children":412},{"style":103},[413],{"type":37,"value":414},"() ",{"type":32,"tag":79,"props":416,"children":417},{"style":282},[418],{"type":37,"value":419},"\u002F\u002F Estrai gli slug dall'API\n",{"type":32,"tag":79,"props":421,"children":422},{"class":81,"line":147},[423,428,433,437,442,447],{"type":32,"tag":79,"props":424,"children":425},{"style":103},[426],{"type":37,"value":427},"    products.",{"type":32,"tag":79,"props":429,"children":430},{"style":97},[431],{"type":37,"value":432},"forEach",{"type":32,"tag":79,"props":434,"children":435},{"style":103},[436],{"type":37,"value":345},{"type":32,"tag":79,"props":438,"children":439},{"style":309},[440],{"type":37,"value":441},"slug",{"type":32,"tag":79,"props":443,"children":444},{"style":86},[445],{"type":37,"value":446}," =>",{"type":32,"tag":79,"props":448,"children":449},{"style":103},[450],{"type":37,"value":327},{"type":32,"tag":79,"props":452,"children":453},{"class":81,"line":177},[454,459,464,468,473,477,482],{"type":32,"tag":79,"props":455,"children":456},{"style":103},[457],{"type":37,"value":458},"      ctx.routes.",{"type":32,"tag":79,"props":460,"children":461},{"style":97},[462],{"type":37,"value":463},"add",{"type":32,"tag":79,"props":465,"children":466},{"style":103},[467],{"type":37,"value":345},{"type":32,"tag":79,"props":469,"children":470},{"style":156},[471],{"type":37,"value":472},"`\u002Fproducts\u002F${",{"type":32,"tag":79,"props":474,"children":475},{"style":103},[476],{"type":37,"value":441},{"type":32,"tag":79,"props":478,"children":479},{"style":156},[480],{"type":37,"value":481},"}`",{"type":32,"tag":79,"props":483,"children":484},{"style":103},[485],{"type":37,"value":486},")\n",{"type":32,"tag":79,"props":488,"children":489},{"class":81,"line":205},[490],{"type":32,"tag":79,"props":491,"children":492},{"style":103},[493],{"type":37,"value":494},"    })\n",{"type":32,"tag":79,"props":496,"children":497},{"class":81,"line":26},[498],{"type":32,"tag":79,"props":499,"children":500},{"style":103},[501],{"type":37,"value":502},"  })\n",{"type":32,"tag":79,"props":504,"children":505},{"class":81,"line":222},[506],{"type":32,"tag":79,"props":507,"children":508},{"style":103},[509],{"type":37,"value":228},{"type":32,"tag":33,"props":511,"children":512},{},[513,515,521],{"type":37,"value":514},"Questo pattern ti permette di estrarre la lista delle route da una fonte dati esterna in fase di build (CMS, database, API commerce headless) e scriverla come HTML statico nella directory ",{"type":32,"tag":52,"props":516,"children":518},{"className":517},[],[519],{"type":37,"value":520},".output\u002Fpublic",{"type":37,"value":522},". Puoi prerendere 5 mila prodotti da un'API Shopify Storefront e deployare su Cloudflare Pages — il TTFB rimane sotto i 20ms.",{"type":32,"tag":40,"props":524,"children":526},{"id":525},"route-rules-strategia-di-rendering-ibrido",[527],{"type":37,"value":528},"Route Rules: Strategia di Rendering Ibrido",{"type":32,"tag":33,"props":530,"children":531},{},[532,534,540,542,551],{"type":37,"value":533},"La funzionalità più potente di Nuxt 3 è la configurazione della modalità di rendering a livello di route. Con ",{"type":32,"tag":52,"props":535,"children":537},{"className":536},[],[538],{"type":37,"value":539},"routeRules",{"type":37,"value":541}," puoi rendere una pagina come SSG mentre un'altra come SSR, e un'altra ancora in modalità SPA. Questo è critico nei progetti ",{"type":32,"tag":543,"props":544,"children":548},"a",{"href":545,"rel":546},"https:\u002F\u002Fwww.roibase.com.tr\u002Fit\u002Fheadless",[547],"nofollow",[549],{"type":37,"value":550},"commerce headless",{"type":37,"value":552}," — le pagine di prodotto statiche, la pagina del carrello client-side, il checkout SSR.",{"type":32,"tag":69,"props":554,"children":556},{"className":71,"code":555,"language":73,"meta":16,"style":16},"export default defineNuxtConfig({\n  routeRules: {\n    '\u002F': { prerender: true },\n    '\u002Fproducts\u002F**': { prerender: true },\n    '\u002Fapi\u002F**': { cors: true },\n    '\u002Fadmin\u002F**': { ssr: false },\n    '\u002Fcart': { ssr: false }\n  }\n})\n",[557],{"type":32,"tag":52,"props":558,"children":559},{"__ignoreMap":16},[560,579,587,609,629,650,672,693,700],{"type":32,"tag":79,"props":561,"children":562},{"class":81,"line":82},[563,567,571,575],{"type":32,"tag":79,"props":564,"children":565},{"style":86},[566],{"type":37,"value":89},{"type":32,"tag":79,"props":568,"children":569},{"style":86},[570],{"type":37,"value":94},{"type":32,"tag":79,"props":572,"children":573},{"style":97},[574],{"type":37,"value":100},{"type":32,"tag":79,"props":576,"children":577},{"style":103},[578],{"type":37,"value":106},{"type":32,"tag":79,"props":580,"children":581},{"class":81,"line":109},[582],{"type":32,"tag":79,"props":583,"children":584},{"style":103},[585],{"type":37,"value":586},"  routeRules: {\n",{"type":32,"tag":79,"props":588,"children":589},{"class":81,"line":118},[590,595,600,604],{"type":32,"tag":79,"props":591,"children":592},{"style":156},[593],{"type":37,"value":594},"    '\u002F'",{"type":32,"tag":79,"props":596,"children":597},{"style":103},[598],{"type":37,"value":599},": { prerender: ",{"type":32,"tag":79,"props":601,"children":602},{"style":136},[603],{"type":37,"value":139},{"type":32,"tag":79,"props":605,"children":606},{"style":103},[607],{"type":37,"value":608}," },\n",{"type":32,"tag":79,"props":610,"children":611},{"class":81,"line":127},[612,617,621,625],{"type":32,"tag":79,"props":613,"children":614},{"style":156},[615],{"type":37,"value":616},"    '\u002Fproducts\u002F**'",{"type":32,"tag":79,"props":618,"children":619},{"style":103},[620],{"type":37,"value":599},{"type":32,"tag":79,"props":622,"children":623},{"style":136},[624],{"type":37,"value":139},{"type":32,"tag":79,"props":626,"children":627},{"style":103},[628],{"type":37,"value":608},{"type":32,"tag":79,"props":630,"children":631},{"class":81,"line":147},[632,637,642,646],{"type":32,"tag":79,"props":633,"children":634},{"style":156},[635],{"type":37,"value":636},"    '\u002Fapi\u002F**'",{"type":32,"tag":79,"props":638,"children":639},{"style":103},[640],{"type":37,"value":641},": { cors: ",{"type":32,"tag":79,"props":643,"children":644},{"style":136},[645],{"type":37,"value":139},{"type":32,"tag":79,"props":647,"children":648},{"style":103},[649],{"type":37,"value":608},{"type":32,"tag":79,"props":651,"children":652},{"class":81,"line":177},[653,658,663,668],{"type":32,"tag":79,"props":654,"children":655},{"style":156},[656],{"type":37,"value":657},"    '\u002Fadmin\u002F**'",{"type":32,"tag":79,"props":659,"children":660},{"style":103},[661],{"type":37,"value":662},": { ssr: ",{"type":32,"tag":79,"props":664,"children":665},{"style":136},[666],{"type":37,"value":667},"false",{"type":32,"tag":79,"props":669,"children":670},{"style":103},[671],{"type":37,"value":608},{"type":32,"tag":79,"props":673,"children":674},{"class":81,"line":205},[675,680,684,688],{"type":32,"tag":79,"props":676,"children":677},{"style":156},[678],{"type":37,"value":679},"    '\u002Fcart'",{"type":32,"tag":79,"props":681,"children":682},{"style":103},[683],{"type":37,"value":662},{"type":32,"tag":79,"props":685,"children":686},{"style":136},[687],{"type":37,"value":667},{"type":32,"tag":79,"props":689,"children":690},{"style":103},[691],{"type":37,"value":692}," }\n",{"type":32,"tag":79,"props":694,"children":695},{"class":81,"line":26},[696],{"type":32,"tag":79,"props":697,"children":698},{"style":103},[699],{"type":37,"value":219},{"type":32,"tag":79,"props":701,"children":702},{"class":81,"line":222},[703],{"type":32,"tag":79,"props":704,"children":705},{"style":103},[706],{"type":37,"value":228},{"type":32,"tag":33,"props":708,"children":709},{},[710],{"type":37,"value":711},"Questa configurazione esegue:",{"type":32,"tag":713,"props":714,"children":715},"ul",{},[716,730,743,756],{"type":32,"tag":717,"props":718,"children":719},"li",{},[720,722,728],{"type":37,"value":721},"La homepage e tutte le route ",{"type":32,"tag":52,"props":723,"children":725},{"className":724},[],[726],{"type":37,"value":727},"\u002Fproducts\u002F*",{"type":37,"value":729}," vengono prerendere in fase di build (SSG)",{"type":32,"tag":717,"props":731,"children":732},{},[733,735,741],{"type":37,"value":734},"Le pagine in ",{"type":32,"tag":52,"props":736,"children":738},{"className":737},[],[739],{"type":37,"value":740},"\u002Fadmin",{"type":37,"value":742}," vengono eseguite in modalità SPA (rendering client-side)",{"type":32,"tag":717,"props":744,"children":745},{},[746,748,754],{"type":37,"value":747},"La pagina ",{"type":32,"tag":52,"props":749,"children":751},{"className":750},[],[752],{"type":37,"value":753},"\u002Fcart",{"type":37,"value":755}," è anche client-side — lo stato del carrello è locale, le richieste API avvengono nel browser",{"type":32,"tag":717,"props":757,"children":758},{},[759,761,767],{"type":37,"value":760},"Gli endpoint ",{"type":32,"tag":52,"props":762,"children":764},{"className":763},[],[765],{"type":37,"value":766},"\u002Fapi",{"type":37,"value":768}," ricevono header CORS (middleware server)",{"type":32,"tag":251,"props":770,"children":772},{"id":771},"isr-incremental-static-regeneration",[773],{"type":37,"value":774},"ISR (Incremental Static Regeneration)",{"type":32,"tag":33,"props":776,"children":777},{},[778,780,786],{"type":37,"value":779},"In Nuxt 3, l'ISR non è ancora maturo come in Next.js, ma con la strategia di cache ",{"type":32,"tag":52,"props":781,"children":783},{"className":782},[],[784],{"type":37,"value":785},"swr",{"type":37,"value":787}," puoi ottenere un comportamento simile:",{"type":32,"tag":69,"props":789,"children":791},{"className":71,"code":790,"language":73,"meta":16,"style":16},"routeRules: {\n  '\u002Fblog\u002F**': { swr: 3600 } \u002F\u002F Cache per 1 ora, poi revalidate\n}\n",[792],{"type":32,"tag":52,"props":793,"children":794},{"__ignoreMap":16},[795,807,835],{"type":32,"tag":79,"props":796,"children":797},{"class":81,"line":82},[798,802],{"type":32,"tag":79,"props":799,"children":800},{"style":97},[801],{"type":37,"value":539},{"type":32,"tag":79,"props":803,"children":804},{"style":103},[805],{"type":37,"value":806},": {\n",{"type":32,"tag":79,"props":808,"children":809},{"class":81,"line":109},[810,815,820,825,830],{"type":32,"tag":79,"props":811,"children":812},{"style":156},[813],{"type":37,"value":814},"  '\u002Fblog\u002F**'",{"type":32,"tag":79,"props":816,"children":817},{"style":103},[818],{"type":37,"value":819},": { swr: ",{"type":32,"tag":79,"props":821,"children":822},{"style":136},[823],{"type":37,"value":824},"3600",{"type":32,"tag":79,"props":826,"children":827},{"style":103},[828],{"type":37,"value":829}," } ",{"type":32,"tag":79,"props":831,"children":832},{"style":282},[833],{"type":37,"value":834},"\u002F\u002F Cache per 1 ora, poi revalidate\n",{"type":32,"tag":79,"props":836,"children":837},{"class":81,"line":118},[838],{"type":32,"tag":79,"props":839,"children":840},{"style":103},[841],{"type":37,"value":842},"}\n",{"type":32,"tag":33,"props":844,"children":845},{},[846,847,853],{"type":37,"value":233},{"type":32,"tag":52,"props":848,"children":850},{"className":849},[],[851],{"type":37,"value":852},"swr: 3600",{"type":37,"value":854}," dice: il primo visitatore riceve HTML statico, la cache scade dopo 1 ora, la richiesta successiva innesca un nuovo render ma mostra la cache vecchia (stale-while-revalidate). Questo è adatto ai siti che richiedono aggiornamenti 24\u002F7 ma non vogliono ricostruire tutte le pagine ad ogni build. In produzione, combinato con la cache edge della CDN (Cloudflare, Vercel), il TTFB rimane sotto 50ms.",{"type":32,"tag":40,"props":856,"children":858},{"id":857},"ottimizzazione-build-rendering-parallelo-e-code-splitting",[859],{"type":37,"value":860},"Ottimizzazione Build: Rendering Parallelo e Code Splitting",{"type":32,"tag":33,"props":862,"children":863},{},[864,866,872],{"type":37,"value":865},"Quando buildi un sito con 5 mila pagine usando ",{"type":32,"tag":52,"props":867,"children":869},{"className":868},[],[870],{"type":37,"value":871},"nuxt generate",{"type":37,"value":873}," con le impostazioni di default, potrebbe volerci 15-20 minuti. Per ridurlo a 5 minuti servono rendering parallelo e code splitting.",{"type":32,"tag":69,"props":875,"children":877},{"className":71,"code":876,"language":73,"meta":16,"style":16},"export default defineNuxtConfig({\n  nitro: {\n    prerender: {\n      concurrency: 20, \u002F\u002F Numero di worker di rendering paralleli\n      interval: 100,   \u002F\u002F Ritardo tra i worker (ms)\n      crawlLinks: false \u002F\u002F Usa iniezione manuale di route\n    }\n  },\n  vite: {\n    build: {\n      rollupOptions: {\n        output: {\n          manualChunks: {\n            'vendor-vue': ['vue', 'vue-router'],\n            'vendor-ui': ['@headlessui\u002Fvue', '@heroicons\u002Fvue']\n          }\n        }\n      }\n    }\n  }\n})\n",[878],{"type":32,"tag":52,"props":879,"children":880},{"__ignoreMap":16},[881,900,907,914,936,959,975,982,990,998,1007,1016,1025,1034,1066,1097,1106,1115,1124,1132,1140],{"type":32,"tag":79,"props":882,"children":883},{"class":81,"line":82},[884,888,892,896],{"type":32,"tag":79,"props":885,"children":886},{"style":86},[887],{"type":37,"value":89},{"type":32,"tag":79,"props":889,"children":890},{"style":86},[891],{"type":37,"value":94},{"type":32,"tag":79,"props":893,"children":894},{"style":97},[895],{"type":37,"value":100},{"type":32,"tag":79,"props":897,"children":898},{"style":103},[899],{"type":37,"value":106},{"type":32,"tag":79,"props":901,"children":902},{"class":81,"line":109},[903],{"type":32,"tag":79,"props":904,"children":905},{"style":103},[906],{"type":37,"value":115},{"type":32,"tag":79,"props":908,"children":909},{"class":81,"line":118},[910],{"type":32,"tag":79,"props":911,"children":912},{"style":103},[913],{"type":37,"value":124},{"type":32,"tag":79,"props":915,"children":916},{"class":81,"line":127},[917,922,927,931],{"type":32,"tag":79,"props":918,"children":919},{"style":103},[920],{"type":37,"value":921},"      concurrency: ",{"type":32,"tag":79,"props":923,"children":924},{"style":136},[925],{"type":37,"value":926},"20",{"type":32,"tag":79,"props":928,"children":929},{"style":103},[930],{"type":37,"value":164},{"type":32,"tag":79,"props":932,"children":933},{"style":282},[934],{"type":37,"value":935},"\u002F\u002F Numero di worker di rendering paralleli\n",{"type":32,"tag":79,"props":937,"children":938},{"class":81,"line":147},[939,944,949,954],{"type":32,"tag":79,"props":940,"children":941},{"style":103},[942],{"type":37,"value":943},"      interval: ",{"type":32,"tag":79,"props":945,"children":946},{"style":136},[947],{"type":37,"value":948},"100",{"type":32,"tag":79,"props":950,"children":951},{"style":103},[952],{"type":37,"value":953},",   ",{"type":32,"tag":79,"props":955,"children":956},{"style":282},[957],{"type":37,"value":958},"\u002F\u002F Ritardo tra i worker (ms)\n",{"type":32,"tag":79,"props":960,"children":961},{"class":81,"line":177},[962,966,970],{"type":32,"tag":79,"props":963,"children":964},{"style":103},[965],{"type":37,"value":133},{"type":32,"tag":79,"props":967,"children":968},{"style":136},[969],{"type":37,"value":667},{"type":32,"tag":79,"props":971,"children":972},{"style":282},[973],{"type":37,"value":974}," \u002F\u002F Usa iniezione manuale di route\n",{"type":32,"tag":79,"props":976,"children":977},{"class":81,"line":205},[978],{"type":32,"tag":79,"props":979,"children":980},{"style":103},[981],{"type":37,"value":211},{"type":32,"tag":79,"props":983,"children":984},{"class":81,"line":26},[985],{"type":32,"tag":79,"props":986,"children":987},{"style":103},[988],{"type":37,"value":989},"  },\n",{"type":32,"tag":79,"props":991,"children":992},{"class":81,"line":222},[993],{"type":32,"tag":79,"props":994,"children":995},{"style":103},[996],{"type":37,"value":997},"  vite: {\n",{"type":32,"tag":79,"props":999,"children":1001},{"class":81,"line":1000},10,[1002],{"type":32,"tag":79,"props":1003,"children":1004},{"style":103},[1005],{"type":37,"value":1006},"    build: {\n",{"type":32,"tag":79,"props":1008,"children":1010},{"class":81,"line":1009},11,[1011],{"type":32,"tag":79,"props":1012,"children":1013},{"style":103},[1014],{"type":37,"value":1015},"      rollupOptions: {\n",{"type":32,"tag":79,"props":1017,"children":1019},{"class":81,"line":1018},12,[1020],{"type":32,"tag":79,"props":1021,"children":1022},{"style":103},[1023],{"type":37,"value":1024},"        output: {\n",{"type":32,"tag":79,"props":1026,"children":1028},{"class":81,"line":1027},13,[1029],{"type":32,"tag":79,"props":1030,"children":1031},{"style":103},[1032],{"type":37,"value":1033},"          manualChunks: {\n",{"type":32,"tag":79,"props":1035,"children":1037},{"class":81,"line":1036},14,[1038,1043,1048,1053,1057,1062],{"type":32,"tag":79,"props":1039,"children":1040},{"style":156},[1041],{"type":37,"value":1042},"            'vendor-vue'",{"type":32,"tag":79,"props":1044,"children":1045},{"style":103},[1046],{"type":37,"value":1047},": [",{"type":32,"tag":79,"props":1049,"children":1050},{"style":156},[1051],{"type":37,"value":1052},"'vue'",{"type":32,"tag":79,"props":1054,"children":1055},{"style":103},[1056],{"type":37,"value":164},{"type":32,"tag":79,"props":1058,"children":1059},{"style":156},[1060],{"type":37,"value":1061},"'vue-router'",{"type":32,"tag":79,"props":1063,"children":1064},{"style":103},[1065],{"type":37,"value":174},{"type":32,"tag":79,"props":1067,"children":1069},{"class":81,"line":1068},15,[1070,1075,1079,1084,1088,1093],{"type":32,"tag":79,"props":1071,"children":1072},{"style":156},[1073],{"type":37,"value":1074},"            'vendor-ui'",{"type":32,"tag":79,"props":1076,"children":1077},{"style":103},[1078],{"type":37,"value":1047},{"type":32,"tag":79,"props":1080,"children":1081},{"style":156},[1082],{"type":37,"value":1083},"'@headlessui\u002Fvue'",{"type":32,"tag":79,"props":1085,"children":1086},{"style":103},[1087],{"type":37,"value":164},{"type":32,"tag":79,"props":1089,"children":1090},{"style":156},[1091],{"type":37,"value":1092},"'@heroicons\u002Fvue'",{"type":32,"tag":79,"props":1094,"children":1095},{"style":103},[1096],{"type":37,"value":202},{"type":32,"tag":79,"props":1098,"children":1100},{"class":81,"line":1099},16,[1101],{"type":32,"tag":79,"props":1102,"children":1103},{"style":103},[1104],{"type":37,"value":1105},"          }\n",{"type":32,"tag":79,"props":1107,"children":1109},{"class":81,"line":1108},17,[1110],{"type":32,"tag":79,"props":1111,"children":1112},{"style":103},[1113],{"type":37,"value":1114},"        }\n",{"type":32,"tag":79,"props":1116,"children":1118},{"class":81,"line":1117},18,[1119],{"type":32,"tag":79,"props":1120,"children":1121},{"style":103},[1122],{"type":37,"value":1123},"      }\n",{"type":32,"tag":79,"props":1125,"children":1127},{"class":81,"line":1126},19,[1128],{"type":32,"tag":79,"props":1129,"children":1130},{"style":103},[1131],{"type":37,"value":211},{"type":32,"tag":79,"props":1133,"children":1135},{"class":81,"line":1134},20,[1136],{"type":32,"tag":79,"props":1137,"children":1138},{"style":103},[1139],{"type":37,"value":219},{"type":32,"tag":79,"props":1141,"children":1143},{"class":81,"line":1142},21,[1144],{"type":32,"tag":79,"props":1145,"children":1146},{"style":103},[1147],{"type":37,"value":228},{"type":32,"tag":33,"props":1149,"children":1150},{},[1151,1152,1158,1160,1166],{"type":37,"value":233},{"type":32,"tag":52,"props":1153,"children":1155},{"className":1154},[],[1156],{"type":37,"value":1157},"concurrency: 20",{"type":37,"value":1159}," renderizza 20 pagine contemporaneamente. Regolalo in base al numero di core CPU — su una macchina a 8 core 20 è ideale, su 4 core riducilo a 10. L'",{"type":32,"tag":52,"props":1161,"children":1163},{"className":1162},[],[1164],{"type":37,"value":1165},"interval: 100",{"type":37,"value":1167}," serve per evitare di urtare contro il rate limit dell'API — se l'API Shopify ha un limite di 2 req\u002Fs usane 500ms.",{"type":32,"tag":251,"props":1169,"children":1171},{"id":1170},"pipeline-di-ottimizzazione-delle-immagini",[1172],{"type":37,"value":1173},"Pipeline di Ottimizzazione delle Immagini",{"type":32,"tag":33,"props":1175,"children":1176},{},[1177],{"type":37,"value":1178},"Il modulo Nuxt Image ottimizza le immagini in fase di build, ma le impostazioni di default sono insufficienti per la produzione. Generare i formati WebP + AVIF in parallelo raddoppia il tempo di build ma riduce il FID (First Input Delay) di 40ms:",{"type":32,"tag":69,"props":1180,"children":1182},{"className":71,"code":1181,"language":73,"meta":16,"style":16},"export default defineNuxtConfig({\n  image: {\n    provider: 'ipx',\n    ipx: {\n      maxAge: 31536000 \u002F\u002F Cache 1 anno\n    },\n    formats: ['webp', 'avif'],\n    screens: {\n      xs: 320,\n      sm: 640,\n      md: 768,\n      lg: 1024,\n      xl: 1280\n    }\n  }\n})\n",[1183],{"type":32,"tag":52,"props":1184,"children":1185},{"__ignoreMap":16},[1186,1205,1213,1230,1238,1256,1264,1290,1298,1315,1332,1349,1366,1379,1386,1393],{"type":32,"tag":79,"props":1187,"children":1188},{"class":81,"line":82},[1189,1193,1197,1201],{"type":32,"tag":79,"props":1190,"children":1191},{"style":86},[1192],{"type":37,"value":89},{"type":32,"tag":79,"props":1194,"children":1195},{"style":86},[1196],{"type":37,"value":94},{"type":32,"tag":79,"props":1198,"children":1199},{"style":97},[1200],{"type":37,"value":100},{"type":32,"tag":79,"props":1202,"children":1203},{"style":103},[1204],{"type":37,"value":106},{"type":32,"tag":79,"props":1206,"children":1207},{"class":81,"line":109},[1208],{"type":32,"tag":79,"props":1209,"children":1210},{"style":103},[1211],{"type":37,"value":1212},"  image: {\n",{"type":32,"tag":79,"props":1214,"children":1215},{"class":81,"line":118},[1216,1221,1226],{"type":32,"tag":79,"props":1217,"children":1218},{"style":103},[1219],{"type":37,"value":1220},"    provider: ",{"type":32,"tag":79,"props":1222,"children":1223},{"style":156},[1224],{"type":37,"value":1225},"'ipx'",{"type":32,"tag":79,"props":1227,"children":1228},{"style":103},[1229],{"type":37,"value":144},{"type":32,"tag":79,"props":1231,"children":1232},{"class":81,"line":127},[1233],{"type":32,"tag":79,"props":1234,"children":1235},{"style":103},[1236],{"type":37,"value":1237},"    ipx: {\n",{"type":32,"tag":79,"props":1239,"children":1240},{"class":81,"line":147},[1241,1246,1251],{"type":32,"tag":79,"props":1242,"children":1243},{"style":103},[1244],{"type":37,"value":1245},"      maxAge: ",{"type":32,"tag":79,"props":1247,"children":1248},{"style":136},[1249],{"type":37,"value":1250},"31536000",{"type":32,"tag":79,"props":1252,"children":1253},{"style":282},[1254],{"type":37,"value":1255}," \u002F\u002F Cache 1 anno\n",{"type":32,"tag":79,"props":1257,"children":1258},{"class":81,"line":177},[1259],{"type":32,"tag":79,"props":1260,"children":1261},{"style":103},[1262],{"type":37,"value":1263},"    },\n",{"type":32,"tag":79,"props":1265,"children":1266},{"class":81,"line":205},[1267,1272,1277,1281,1286],{"type":32,"tag":79,"props":1268,"children":1269},{"style":103},[1270],{"type":37,"value":1271},"    formats: [",{"type":32,"tag":79,"props":1273,"children":1274},{"style":156},[1275],{"type":37,"value":1276},"'webp'",{"type":32,"tag":79,"props":1278,"children":1279},{"style":103},[1280],{"type":37,"value":164},{"type":32,"tag":79,"props":1282,"children":1283},{"style":156},[1284],{"type":37,"value":1285},"'avif'",{"type":32,"tag":79,"props":1287,"children":1288},{"style":103},[1289],{"type":37,"value":174},{"type":32,"tag":79,"props":1291,"children":1292},{"class":81,"line":26},[1293],{"type":32,"tag":79,"props":1294,"children":1295},{"style":103},[1296],{"type":37,"value":1297},"    screens: {\n",{"type":32,"tag":79,"props":1299,"children":1300},{"class":81,"line":222},[1301,1306,1311],{"type":32,"tag":79,"props":1302,"children":1303},{"style":103},[1304],{"type":37,"value":1305},"      xs: ",{"type":32,"tag":79,"props":1307,"children":1308},{"style":136},[1309],{"type":37,"value":1310},"320",{"type":32,"tag":79,"props":1312,"children":1313},{"style":103},[1314],{"type":37,"value":144},{"type":32,"tag":79,"props":1316,"children":1317},{"class":81,"line":1000},[1318,1323,1328],{"type":32,"tag":79,"props":1319,"children":1320},{"style":103},[1321],{"type":37,"value":1322},"      sm: ",{"type":32,"tag":79,"props":1324,"children":1325},{"style":136},[1326],{"type":37,"value":1327},"640",{"type":32,"tag":79,"props":1329,"children":1330},{"style":103},[1331],{"type":37,"value":144},{"type":32,"tag":79,"props":1333,"children":1334},{"class":81,"line":1009},[1335,1340,1345],{"type":32,"tag":79,"props":1336,"children":1337},{"style":103},[1338],{"type":37,"value":1339},"      md: ",{"type":32,"tag":79,"props":1341,"children":1342},{"style":136},[1343],{"type":37,"value":1344},"768",{"type":32,"tag":79,"props":1346,"children":1347},{"style":103},[1348],{"type":37,"value":144},{"type":32,"tag":79,"props":1350,"children":1351},{"class":81,"line":1018},[1352,1357,1362],{"type":32,"tag":79,"props":1353,"children":1354},{"style":103},[1355],{"type":37,"value":1356},"      lg: ",{"type":32,"tag":79,"props":1358,"children":1359},{"style":136},[1360],{"type":37,"value":1361},"1024",{"type":32,"tag":79,"props":1363,"children":1364},{"style":103},[1365],{"type":37,"value":144},{"type":32,"tag":79,"props":1367,"children":1368},{"class":81,"line":1027},[1369,1374],{"type":32,"tag":79,"props":1370,"children":1371},{"style":103},[1372],{"type":37,"value":1373},"      xl: ",{"type":32,"tag":79,"props":1375,"children":1376},{"style":136},[1377],{"type":37,"value":1378},"1280\n",{"type":32,"tag":79,"props":1380,"children":1381},{"class":81,"line":1036},[1382],{"type":32,"tag":79,"props":1383,"children":1384},{"style":103},[1385],{"type":37,"value":211},{"type":32,"tag":79,"props":1387,"children":1388},{"class":81,"line":1068},[1389],{"type":32,"tag":79,"props":1390,"children":1391},{"style":103},[1392],{"type":37,"value":219},{"type":32,"tag":79,"props":1394,"children":1395},{"class":81,"line":1099},[1396],{"type":32,"tag":79,"props":1397,"children":1398},{"style":103},[1399],{"type":37,"value":228},{"type":32,"tag":33,"props":1401,"children":1402},{},[1403],{"type":37,"value":1404},"Questa configurazione genera immagini responsive — ogni immagine per 5 breakpoint × 2 formati = 10 file. Su un sito con 1000 immagini il tempo di build aumenta di +3 minuti, ma il LCP (Largest Contentful Paint) scende da 2,5s a 1,2s. Il compromesso è netto: il tempo di build è accettabile, l'esperienza dell'utente è critica.",{"type":32,"tag":40,"props":1406,"children":1408},{"id":1407},"deployment-in-produzione-cache-edge-cdn",[1409],{"type":37,"value":1410},"Deployment in Produzione: Cache Edge CDN",{"type":32,"tag":33,"props":1412,"children":1413},{},[1414,1416,1421],{"type":37,"value":1415},"Dopo aver scritto il build SSG nella directory ",{"type":32,"tag":52,"props":1417,"children":1419},{"className":1418},[],[1420],{"type":37,"value":520},{"type":37,"value":1422},", la strategia di deployment è importante. Piattaforme come Cloudflare Pages, Vercel e Netlify applicano la cache edge, ma occorre la configurazione manuale degli header della cache:",{"type":32,"tag":69,"props":1424,"children":1426},{"className":71,"code":1425,"language":73,"meta":16,"style":16},"\u002F\u002F server\u002Fmiddleware\u002Fcache-headers.ts\nexport default defineEventHandler((event) => {\n  const url = event.node.req.url\n  \n  if (url?.startsWith('\u002Fproducts\u002F')) {\n    setResponseHeaders(event, {\n      'Cache-Control': 'public, max-age=3600, s-maxage=86400, stale-while-revalidate=604800'\n    })\n  }\n  \n  if (url?.startsWith('\u002F_nuxt\u002F')) {\n    setResponseHeaders(event, {\n      'Cache-Control': 'public, max-age=31536000, immutable'\n    })\n  }\n})\n",[1427],{"type":32,"tag":52,"props":1428,"children":1429},{"__ignoreMap":16},[1430,1438,1475,1497,1505,1537,1550,1568,1575,1582,1589,1617,1628,1644,1651,1658],{"type":32,"tag":79,"props":1431,"children":1432},{"class":81,"line":82},[1433],{"type":32,"tag":79,"props":1434,"children":1435},{"style":282},[1436],{"type":37,"value":1437},"\u002F\u002F server\u002Fmiddleware\u002Fcache-headers.ts\n",{"type":32,"tag":79,"props":1439,"children":1440},{"class":81,"line":109},[1441,1445,1449,1454,1458,1463,1467,1471],{"type":32,"tag":79,"props":1442,"children":1443},{"style":86},[1444],{"type":37,"value":89},{"type":32,"tag":79,"props":1446,"children":1447},{"style":86},[1448],{"type":37,"value":94},{"type":32,"tag":79,"props":1450,"children":1451},{"style":97},[1452],{"type":37,"value":1453}," defineEventHandler",{"type":32,"tag":79,"props":1455,"children":1456},{"style":103},[1457],{"type":37,"value":306},{"type":32,"tag":79,"props":1459,"children":1460},{"style":309},[1461],{"type":37,"value":1462},"event",{"type":32,"tag":79,"props":1464,"children":1465},{"style":103},[1466],{"type":37,"value":317},{"type":32,"tag":79,"props":1468,"children":1469},{"style":86},[1470],{"type":37,"value":322},{"type":32,"tag":79,"props":1472,"children":1473},{"style":103},[1474],{"type":37,"value":327},{"type":32,"tag":79,"props":1476,"children":1477},{"class":81,"line":118},[1478,1483,1488,1492],{"type":32,"tag":79,"props":1479,"children":1480},{"style":86},[1481],{"type":37,"value":1482},"  const",{"type":32,"tag":79,"props":1484,"children":1485},{"style":136},[1486],{"type":37,"value":1487}," url",{"type":32,"tag":79,"props":1489,"children":1490},{"style":86},[1491],{"type":37,"value":399},{"type":32,"tag":79,"props":1493,"children":1494},{"style":103},[1495],{"type":37,"value":1496}," event.node.req.url\n",{"type":32,"tag":79,"props":1498,"children":1499},{"class":81,"line":127},[1500],{"type":32,"tag":79,"props":1501,"children":1502},{"style":103},[1503],{"type":37,"value":1504},"  \n",{"type":32,"tag":79,"props":1506,"children":1507},{"class":81,"line":147},[1508,1513,1518,1523,1527,1532],{"type":32,"tag":79,"props":1509,"children":1510},{"style":86},[1511],{"type":37,"value":1512},"  if",{"type":32,"tag":79,"props":1514,"children":1515},{"style":103},[1516],{"type":37,"value":1517}," (url?.",{"type":32,"tag":79,"props":1519,"children":1520},{"style":97},[1521],{"type":37,"value":1522},"startsWith",{"type":32,"tag":79,"props":1524,"children":1525},{"style":103},[1526],{"type":37,"value":345},{"type":32,"tag":79,"props":1528,"children":1529},{"style":156},[1530],{"type":37,"value":1531},"'\u002Fproducts\u002F'",{"type":32,"tag":79,"props":1533,"children":1534},{"style":103},[1535],{"type":37,"value":1536},")) {\n",{"type":32,"tag":79,"props":1538,"children":1539},{"class":81,"line":177},[1540,1545],{"type":32,"tag":79,"props":1541,"children":1542},{"style":97},[1543],{"type":37,"value":1544},"    setResponseHeaders",{"type":32,"tag":79,"props":1546,"children":1547},{"style":103},[1548],{"type":37,"value":1549},"(event, {\n",{"type":32,"tag":79,"props":1551,"children":1552},{"class":81,"line":205},[1553,1558,1563],{"type":32,"tag":79,"props":1554,"children":1555},{"style":156},[1556],{"type":37,"value":1557},"      'Cache-Control'",{"type":32,"tag":79,"props":1559,"children":1560},{"style":103},[1561],{"type":37,"value":1562},": ",{"type":32,"tag":79,"props":1564,"children":1565},{"style":156},[1566],{"type":37,"value":1567},"'public, max-age=3600, s-maxage=86400, stale-while-revalidate=604800'\n",{"type":32,"tag":79,"props":1569,"children":1570},{"class":81,"line":26},[1571],{"type":32,"tag":79,"props":1572,"children":1573},{"style":103},[1574],{"type":37,"value":494},{"type":32,"tag":79,"props":1576,"children":1577},{"class":81,"line":222},[1578],{"type":32,"tag":79,"props":1579,"children":1580},{"style":103},[1581],{"type":37,"value":219},{"type":32,"tag":79,"props":1583,"children":1584},{"class":81,"line":1000},[1585],{"type":32,"tag":79,"props":1586,"children":1587},{"style":103},[1588],{"type":37,"value":1504},{"type":32,"tag":79,"props":1590,"children":1591},{"class":81,"line":1009},[1592,1596,1600,1604,1608,1613],{"type":32,"tag":79,"props":1593,"children":1594},{"style":86},[1595],{"type":37,"value":1512},{"type":32,"tag":79,"props":1597,"children":1598},{"style":103},[1599],{"type":37,"value":1517},{"type":32,"tag":79,"props":1601,"children":1602},{"style":97},[1603],{"type":37,"value":1522},{"type":32,"tag":79,"props":1605,"children":1606},{"style":103},[1607],{"type":37,"value":345},{"type":32,"tag":79,"props":1609,"children":1610},{"style":156},[1611],{"type":37,"value":1612},"'\u002F_nuxt\u002F'",{"type":32,"tag":79,"props":1614,"children":1615},{"style":103},[1616],{"type":37,"value":1536},{"type":32,"tag":79,"props":1618,"children":1619},{"class":81,"line":1018},[1620,1624],{"type":32,"tag":79,"props":1621,"children":1622},{"style":97},[1623],{"type":37,"value":1544},{"type":32,"tag":79,"props":1625,"children":1626},{"style":103},[1627],{"type":37,"value":1549},{"type":32,"tag":79,"props":1629,"children":1630},{"class":81,"line":1027},[1631,1635,1639],{"type":32,"tag":79,"props":1632,"children":1633},{"style":156},[1634],{"type":37,"value":1557},{"type":32,"tag":79,"props":1636,"children":1637},{"style":103},[1638],{"type":37,"value":1562},{"type":32,"tag":79,"props":1640,"children":1641},{"style":156},[1642],{"type":37,"value":1643},"'public, max-age=31536000, immutable'\n",{"type":32,"tag":79,"props":1645,"children":1646},{"class":81,"line":1036},[1647],{"type":32,"tag":79,"props":1648,"children":1649},{"style":103},[1650],{"type":37,"value":494},{"type":32,"tag":79,"props":1652,"children":1653},{"class":81,"line":1068},[1654],{"type":32,"tag":79,"props":1655,"children":1656},{"style":103},[1657],{"type":37,"value":219},{"type":32,"tag":79,"props":1659,"children":1660},{"class":81,"line":1099},[1661],{"type":32,"tag":79,"props":1662,"children":1663},{"style":103},[1664],{"type":37,"value":228},{"type":32,"tag":33,"props":1666,"children":1667},{},[1668],{"type":37,"value":1669},"Questo middleware esegue:",{"type":32,"tag":713,"props":1671,"children":1672},{},[1673,1685],{"type":32,"tag":717,"props":1674,"children":1675},{},[1676,1678,1683],{"type":37,"value":1677},"Le route ",{"type":32,"tag":52,"props":1679,"children":1681},{"className":1680},[],[1682],{"type":37,"value":727},{"type":37,"value":1684}," vengono cachate 1 ora nel browser, 1 giorno sulla CDN, cache stale servita per 1 settimana",{"type":32,"tag":717,"props":1686,"children":1687},{},[1688,1690,1696],{"type":37,"value":1689},"Gli asset statici ",{"type":32,"tag":52,"props":1691,"children":1693},{"className":1692},[],[1694],{"type":37,"value":1695},"\u002F_nuxt\u002F*",{"type":37,"value":1697}," (JS, CSS) vengono cachati 1 anno immutable — fintanto che l'hash del build non cambia non c'è refetch",{"type":32,"tag":33,"props":1699,"children":1700},{},[1701],{"type":37,"value":1702},"Con i dati di Analytics di Cloudflare abbiamo testato: il cache hit rate sale dal 92% al 98%, il TTFB medio scende da 180ms a 25ms. Senza la cache edge, l'SSG non ha senso — anche se l'HTML è statico, la latenza di rete uccide le prestazioni.",{"type":32,"tag":40,"props":1704,"children":1706},{"id":1705},"scenari-di-errore-e-fallback",[1707],{"type":37,"value":1708},"Scenari di Errore e Fallback",{"type":32,"tag":33,"props":1710,"children":1711},{},[1712,1714,1720],{"type":37,"value":1713},"Se una route fallisce durante il prerender (timeout API, 404), il build fallisce. In produzione, per gestirlo occorre un meccanismo di fallback nell'hook ",{"type":32,"tag":52,"props":1715,"children":1717},{"className":1716},[],[1718],{"type":37,"value":1719},"onPrerender",{"type":37,"value":1721},":",{"type":32,"tag":69,"props":1723,"children":1725},{"className":71,"code":1724,"language":73,"meta":16,"style":16},"nitroApp.hooks.hook('prerender:route', (route) => {\n  if (route.error) {\n    console.warn(`Failed to prerender: ${route.route}`)\n    route.skip = true \u002F\u002F Salta questa route, non interrompere il build\n  }\n})\n",[1726],{"type":32,"tag":52,"props":1727,"children":1728},{"__ignoreMap":16},[1729,1772,1784,1827,1850,1857],{"type":32,"tag":79,"props":1730,"children":1731},{"class":81,"line":82},[1732,1737,1741,1745,1750,1755,1760,1764,1768],{"type":32,"tag":79,"props":1733,"children":1734},{"style":103},[1735],{"type":37,"value":1736},"nitroApp.hooks.",{"type":32,"tag":79,"props":1738,"children":1739},{"style":97},[1740],{"type":37,"value":340},{"type":32,"tag":79,"props":1742,"children":1743},{"style":103},[1744],{"type":37,"value":345},{"type":32,"tag":79,"props":1746,"children":1747},{"style":156},[1748],{"type":37,"value":1749},"'prerender:route'",{"type":32,"tag":79,"props":1751,"children":1752},{"style":103},[1753],{"type":37,"value":1754},", (",{"type":32,"tag":79,"props":1756,"children":1757},{"style":309},[1758],{"type":37,"value":1759},"route",{"type":32,"tag":79,"props":1761,"children":1762},{"style":103},[1763],{"type":37,"value":317},{"type":32,"tag":79,"props":1765,"children":1766},{"style":86},[1767],{"type":37,"value":322},{"type":32,"tag":79,"props":1769,"children":1770},{"style":103},[1771],{"type":37,"value":327},{"type":32,"tag":79,"props":1773,"children":1774},{"class":81,"line":109},[1775,1779],{"type":32,"tag":79,"props":1776,"children":1777},{"style":86},[1778],{"type":37,"value":1512},{"type":32,"tag":79,"props":1780,"children":1781},{"style":103},[1782],{"type":37,"value":1783}," (route.error) {\n",{"type":32,"tag":79,"props":1785,"children":1786},{"class":81,"line":118},[1787,1792,1797,1801,1806,1810,1815,1819,1823],{"type":32,"tag":79,"props":1788,"children":1789},{"style":103},[1790],{"type":37,"value":1791},"    console.",{"type":32,"tag":79,"props":1793,"children":1794},{"style":97},[1795],{"type":37,"value":1796},"warn",{"type":32,"tag":79,"props":1798,"children":1799},{"style":103},[1800],{"type":37,"value":345},{"type":32,"tag":79,"props":1802,"children":1803},{"style":156},[1804],{"type":37,"value":1805},"`Failed to prerender: ${",{"type":32,"tag":79,"props":1807,"children":1808},{"style":103},[1809],{"type":37,"value":1759},{"type":32,"tag":79,"props":1811,"children":1812},{"style":156},[1813],{"type":37,"value":1814},".",{"type":32,"tag":79,"props":1816,"children":1817},{"style":103},[1818],{"type":37,"value":1759},{"type":32,"tag":79,"props":1820,"children":1821},{"style":156},[1822],{"type":37,"value":481},{"type":32,"tag":79,"props":1824,"children":1825},{"style":103},[1826],{"type":37,"value":486},{"type":32,"tag":79,"props":1828,"children":1829},{"class":81,"line":127},[1830,1835,1840,1845],{"type":32,"tag":79,"props":1831,"children":1832},{"style":103},[1833],{"type":37,"value":1834},"    route.skip ",{"type":32,"tag":79,"props":1836,"children":1837},{"style":86},[1838],{"type":37,"value":1839},"=",{"type":32,"tag":79,"props":1841,"children":1842},{"style":136},[1843],{"type":37,"value":1844}," true",{"type":32,"tag":79,"props":1846,"children":1847},{"style":282},[1848],{"type":37,"value":1849}," \u002F\u002F Salta questa route, non interrompere il build\n",{"type":32,"tag":79,"props":1851,"children":1852},{"class":81,"line":147},[1853],{"type":32,"tag":79,"props":1854,"children":1855},{"style":103},[1856],{"type":37,"value":219},{"type":32,"tag":79,"props":1858,"children":1859},{"class":81,"line":177},[1860],{"type":32,"tag":79,"props":1861,"children":1862},{"style":103},[1863],{"type":37,"value":228},{"type":32,"tag":33,"props":1865,"children":1866},{},[1867,1869,1874],{"type":37,"value":1868},"Questo pattern impedisce al build intero di crollare se 50 route su 10 mila falliscono. Per le route fallite mostra una pagina di fallback (404 o una pagina di prodotto generica). Alternativa: passa le route fallite a SSR — renderizzale a runtime con ",{"type":32,"tag":52,"props":1870,"children":1872},{"className":1871},[],[1873],{"type":37,"value":539},{"type":37,"value":1814},{"type":32,"tag":33,"props":1876,"children":1877},{},[1878],{"type":37,"value":1879},"L'architettura SSG di Nuxt 3 offre flessibilità, ma senza la giusta configurazione il tempo di build e le prestazioni runtime diventano un problema. La combinazione di route rules per rendering ibrido, prerendering parallelo, strategia di cache CDN e meccanismi di fallback produce risultati production-grade. Puoi buildare un sito di e-commerce con 5 mila pagine in 5 minuti e servire con 25ms di TTFB — devi solo sapere quale leva di Nitro tirare.",{"type":32,"tag":1881,"props":1882,"children":1883},"style",{},[1884],{"type":37,"value":1885},"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":118,"depth":118,"links":1887},[1888,1891,1894,1897,1898],{"id":42,"depth":109,"text":45,"children":1889},[1890],{"id":253,"depth":118,"text":256},{"id":525,"depth":109,"text":528,"children":1892},[1893],{"id":771,"depth":118,"text":774},{"id":857,"depth":109,"text":860,"children":1895},[1896],{"id":1170,"depth":118,"text":1173},{"id":1407,"depth":109,"text":1410},{"id":1705,"depth":109,"text":1708},"markdown","content:it:tech:ssg-strategie-nuxt-3-prerender-e-ottimizzazione-build.md","content","it\u002Ftech\u002Fssg-strategie-nuxt-3-prerender-e-ottimizzazione-build.md","it\u002Ftech\u002Fssg-strategie-nuxt-3-prerender-e-ottimizzazione-build","md",1786860289594]