0Pricing
AWS for Backend Developers (EC2, S3, RDS, Lambda) · Lección

Alojamiento de sitios web estáticos y distribución mediante CDN

Sirva un sitio web estático directamente desde un bucket de S3 y acelere su distribución global con una CDN de CloudFront delante.

Alojamiento de sitios web estáticos y distribución mediante CDN es una lección gratuita de AWS for Backend Developers (EC2, S3, RDS, Lambda) en CoddyKit. Esta es la lección 4 de 4. Puedes leer la lección completa abajo gratuitamente — luego la practicas en el navegador con un editor de código integrado y un tutor de IA 24/7. Forma parte de la ruta de aprendizaje de AWS for Backend Developers (EC2, S3, RDS, Lambda), y tu progreso se sincroniza en la web y la app de CoddyKit. El curso de AWS for Backend Developers (EC2, S3, RDS, Lambda) incluye 4 lecciones en total.

Partes de esta lección aún no han sido traducidas y se muestran en inglés.

S3 as a Web Server

Beyond storing files, S3 can host a static website, HTML, CSS, JS, and images, with no servers to manage. It is cheap, scalable, and a perfect fit for single-page apps and documentation sites.

Enabling Static Hosting

You enable the static website hosting feature on the bucket and specify an index document (the home page) and an error document.

Index and Error Documents

The index document (often index.html) is served for the root and folder URLs. The error document handles 4xx responses, useful for SPA routing where you point errors back to index.html.

Uploading Your Site

Sync your build output into the bucket. The AWS CLI sync command uploads only changed files.

aws s3 sync ./dist s3://my-site-bucket --delete

Content Types Matter

S3 serves files with the Content-Type stored as metadata. If a CSS file is served as plain text, browsers ignore it. The CLI usually infers types, but verify for unusual extensions.

The Website Endpoint

Static hosting exposes a regional website endpoint URL. It is HTTP only and not ideal for production, which is exactly why we add a CDN next.

http://my-site-bucket.s3-website-us-east-1.amazonaws.com

Introducing CloudFront

CloudFront is AWS's content delivery network. It caches your site at edge locations worldwide, so users get fast responses from a nearby server and your bucket sees less load.

Origins and Distributions

A CloudFront distribution points at an origin (your S3 bucket). CloudFront fetches from the origin on a cache miss and serves the cached copy on subsequent requests.

HTTPS and Custom Domains

CloudFront gives you free HTTPS via AWS Certificate Manager and lets you attach a custom domain like www.example.com, things the raw S3 endpoint cannot do.

Locking Down the Bucket

For security, keep the bucket private and let only CloudFront read it using an Origin Access Control (OAC). Visitors reach content through the CDN, never the bucket directly.

Cache Invalidation

CloudFront caches aggressively. After deploying new content, invalidate the cache so users get the latest version instead of a stale copy.

aws cloudfront create-invalidation \
  --distribution-id E123ABC \
  --paths "/*"

Quick Check

Test your static hosting knowledge.

Recap: Global Static Sites

You can now ship a static site on AWS:

  • Enable S3 static website hosting with index/error documents.
  • aws s3 sync deploys your build.
  • CloudFront adds edge caching, HTTPS, and custom domains.
  • Use OAC to keep the bucket private and invalidate the cache on deploy.

Preguntas frecuentes

¿La lección «Alojamiento de sitios web estáticos y distribución mediante CDN» es gratis?

Sí — el texto completo de «Alojamiento de sitios web estáticos y distribución mediante CDN» es gratis para leer aquí en la web. Para practicarla de forma interactiva (editor de código integrado y tutor de IA 24/7) y desbloquear el resto del curso de AWS for Backend Developers (EC2, S3, RDS, Lambda), actualiza a CoddyKit PRO. El curso de AWS for Backend Developers (EC2, S3, RDS, Lambda) incluye 4 lecciones en total.

¿Qué aprenderé en «Alojamiento de sitios web estáticos y distribución mediante CDN»?

Sirva un sitio web estático directamente desde un bucket de S3 y acelere su distribución global con una CDN de CloudFront delante. Practicas AWS for Backend Developers (EC2, S3, RDS, Lambda) con código real que ejecutas directamente en el navegador, y un tutor de IA 24/7 responde tus preguntas mientras trabajas en la lección.

¿Necesito experiencia previa para empezar AWS for Backend Developers (EC2, S3, RDS, Lambda)?

No se requiere experiencia previa. AWS for Backend Developers (EC2, S3, RDS, Lambda) en CoddyKit está estructurado para principiantes hasta estudiantes avanzados, así que puedes empezar aquí o desde el inicio y avanzar a tu ritmo. Esta es la lección 4 de 4.

¿Cuánto tiempo toma la lección «Alojamiento de sitios web estáticos y distribución mediante CDN»?

La mayoría de las lecciones de CoddyKit toman alrededor de 5–10 minutos. Cada una es compacta e interactiva, así que avanzas constantemente y retomas exactamente por donde dejaste en la web y la app.

¿Puedo escribir y ejecutar código en esta lección de AWS for Backend Developers (EC2, S3, RDS, Lambda)?

Sí. Cada lección de AWS for Backend Developers (EC2, S3, RDS, Lambda) incluye un editor de código integrado, así que escribes y ejecutas código real directamente en tu navegador y obtienes retroalimentación instantánea de IA — sin configuración local necesaria.

Todas las lecciones de este curso

  1. Buckets y objetos de S3 explicados
  2. Versionado y políticas de ciclo de vida de S3
  3. Protección del acceso a los datos de S3
  4. Alojamiento de sitios web estáticos y distribución mediante CDN
← Volver a AWS for Backend Developers (EC2, S3, RDS, Lambda)