Summary
The Static Content Hosting pattern deploys static content (HTML, CSS, JavaScript, images, documents) to a cloud-based storage service instead of hosting it on application servers. This offloads compute resources, reduces cost, and improves access performance. Content is uploaded to a storage container with public read access, and clients fetch it directly from the storage endpoint. A Content Delivery Network usually sits in front to cache the files in data centers close to users.
Key Points
- Purpose: Optimize cost and performance by separating the serving of static content from the processing of dynamic logic.
- Benefits:
- Lower cost: Cloud storage (such as Azure Blob Storage) is much cheaper than maintaining server instances (VMs, App Service).
- Scalability: Storage services are designed to handle large numbers of concurrent requests without complex configuration.
- Better performance: Frees web server CPU/RAM to focus on generating dynamic content.
- How it works:
- Static content is uploaded to a storage container with public access (public read).
- Client applications access these resources directly through the storage service's HTTP/HTTPS endpoint.
- Usually combined with a Content Delivery Network (CDN) to cache content in the data centers closest to users around the world.
- Considerations:
- Deployment: Updating the application becomes more complex because you must update both the code on the server and the static content in the storage at the same time.
- Custom domain: You need configuration to use your own domain and HTTPS if required.
- Security: Make sure the storage grants only public "read" access and absolutely no public "write" access. For private content, use the Valet Key mechanism (for example: SAS tokens).
Blob storage costs less than VMs or App Service and handles many concurrent reads. Clients fetch files from the public endpoint or a nearby CDN. A release must update the server and the storage together. Public access stays read only, and private files use a valet key such as a SAS token.
When to Use
- When the application has many static resources such as images, videos, PDF documents, or large script files.
- When you want to build fully static websites (Single Page Applications, SPA).
- When you need to serve content to users in many different geographic regions.
Relationships
- Valet Key Pattern: Used to control access to static resources that must not be fully public.
- Azure Storage Static Website: The specific Azure feature for implementing this pattern.
References
See also: Valet Key Pattern · Cache Aside Pattern · Gateway Offloading Pattern