Files
mercadodevida/work/artifacts/F-132/implementer.md
2026-08-21 17:45:12 +02:00

57 lines
2.6 KiB
Markdown

# F-132 — Quitar `cache: 'no-store'` de los fetches server-side del frontend
## Cambios
### `frontend/src/lib/api.ts`
- `fetchCategories()` → sin `cache: 'no-store'`.
- `fetchProducts(params)` → sin `cache: 'no-store'`.
- `fetchBrandBySlug(slug)` → sin `cache: 'no-store'`.
- `fetchPage(slug)` → sin `cache: 'no-store'`.
- `fetchBrands()` → sin `cache: 'no-store'`.
- `fetchCategoryBySlug(slug)` → sin `cache: 'no-store'`.
- `fetchProductBySlug(slug)` → sin `cache: 'no-store'`.
- `fetchProductVariants(productId)` → sin `cache: 'no-store'`.
- `fetchVariantPrice(variantId)` → sin `cache: 'no-store'`.
- `fetchStockAvailability(variantId)` → sin `cache: 'no-store'`.
- `fetchSearchSuggestions(term)`**mantiene** `cache: 'no-store'` (componente cliente, necesita frescura).
### Páginas con `revalidate`
- `frontend/src/app/products/page.tsx`: `export const revalidate = 3600`.
- `frontend/src/app/products/[slug]/page.tsx`: `export const revalidate = 3600`.
- `frontend/src/app/categories/page.tsx`: `export const revalidate = 3600`.
- `frontend/src/app/categories/[slug]/page.tsx`: `export const revalidate = 3600`.
- `frontend/src/app/brands/page.tsx`: `export const revalidate = 3600`.
- `frontend/src/app/brands/[slug]/page.tsx`: `export const revalidate = 3600`.
### Search
- `frontend/src/app/search/page.tsx`: `export const dynamic = 'force-dynamic'`.
### Uploads
- `frontend/src/app/uploads/[...path]/route.ts`: comentarios `/*turbopackIgnore: true*/` añadidos dentro de las 4 llamadas `path.join(...)` que usan variables runtime.
## Evidencia
- `cd frontend && npx tsc --noEmit` → exit 0.
- `cd frontend && NEXT_PUBLIC_API_URL=http://192.168.18.93:3000 npm run build` → exit 0.
- Tabla de rutas del build:
```
┌ ○ / 1h 1y
├ ○ /brands 1h 1y
├ ƒ /brands/[slug]
├ ○ /categories 1h 1y
├ ƒ /categories/[slug]
├ ○ /products 1h 1y
├ ƒ /products/[slug]
├ ƒ /search
├ ƒ /uploads/[...path]
```
- Búsqueda en la salida del build:
- `DYNAMIC_SERVER_USAGE`: **0 ocurrencias**
- Warnings de filesystem en route.ts: **0 ocurrencias**
- Solo queda un warning no relacionado: "inferred your workspace root" (monorepo).
## Notas
- El operador debe reiniciar el frontend: `monolith.sh prod restart`.
- Las páginas ahora son ISR (1h). Productos recién creados tardarán hasta 1h en aparecer en listados públicos.
- Si se necesita invalidación inmediata, futuro: `revalidatePath` desde admin al guardar.