CDN Setup for Widget Bundles
CDN Service Overview
Audience: Platform teams setting up production CDN infrastructure for their organization.
Your 1fe widgets need to be served from a fast, reliable CDN to ensure optimal performance for users worldwide. This guide covers how to set up and configure CDN services for hosting your widget bundles.
What Your CDN Will Host
- JavaScript bundles - Compiled widget code
- CSS stylesheets - Widget-specific styles
- Source maps - For debugging and error tracking
- Asset files - Images, fonts, icons used by widgets
Akamai CDN Setup
Detailed Akamai NetStorage Setup
We use Akamai NetStorage to host our widget bundles and static assets, but your team can choose any CDN provider that fits your requirements. For more information, see the Alternative CDN Providers section at the bottom of this guide.
Official Documentation: Akamai NetStorage User Guide
Step 1: Create a NetStorage Storage Group
The first step is to create a new storage group in Akamai NetStorage. For official step-by-step instructions, see Create a storage group in the Akamai documentation.
Setup Instructions:
-
Log in to Akamai Control Center
Navigate to Akamai Control Center. -
Navigate to NetStorage
Go to Akamai > NetStorage. -
Start Creating Storage Group
Click the Create button. -
Select Storage Group Type
Select Create Storage Group from the dropdown. -
Set Storage Group Name
Storage Group Name: Choose a unique and descriptive name (e.g.,1fe-Production
). -
Select Contract
Contract: Select your specific contract from the dropdown. -
Select Group
Group: Select the group associated with your contract. -
Configure Primary Replica
Replica No. 1: Select a primary geographic zone (e.g.,us-east
). -
Set Failover Action
Failover Action: Choosespill outside
to ensure content is served from other replicas if the primary fails. -
Configure Upload and Download Permissions
Set Allow upload toYes
Set Allow download toYes
. -
Add Secondary Replica (Recommended)
Click Add Replica to configure redundancy
Select a different geographic zone from the primary replica
This provides redundancy and improved global performance
High Availability Requirement: Always configure at least two replicas in different geographic zones for high availability. This ensures your content remains accessible even if one region experiences issues. -
Finalize Creation
Click Create Storage Group to complete the process. -
Verify Creation
Verify the storage group appears in your NetStorage dashboard
Note the storage group details for future reference.
Official Documentation: Creating Storage Groups
Step 2: Add an Upload Directory
Next, you’ll upload your content to the directory you created within your storage group. Each upload directory is associated with a unique CP Code, which you’ll use for CDN configuration. For step-by-step instructions on uploading content to NetStorage, refer to the official documentation on uploading content.
Setup Instructions:
-
Navigate to NetStorage Storage Groups
Go to NetStorage > Storage Groups page. -
Select Your Storage Group
Select the storage group you just created. -
Access Upload Directories Section
In the details pane, find the Upload directories section. -
Start Creating New Directory
Click the + icon to add a new directory. -
Set Directory Name
Directory Name: Enter a descriptive name (e.g.,production
)
This name becomes part of your file path structure
Choose names that clearly identify the environment or purpose. -
Record the CP Code
The system automatically assigns a unique CP Code
Save this code immediately - you’ll need it for CDN configuration. -
Store CP Code Securely
Store the CP Code in a secure location accessible to your team. -
Configure Download Security
Set Download security toAll edge servers
This allows global content delivery through the CDN. -
Ensure Global Access
This setting ensures your content can be served from all Akamai edge locations. -
Complete Directory Creation
Click Create Directory to finalize the configuration. -
Verify Directory Creation
Verify the directory appears in your Upload directories list.
Step 3: Upload Content to NetStorage
With the storage configured, you can now upload your content using rsync over SSH for efficient and reliable file transfers. For official documentation on uploading to NetStorage with rsync, see Akamai NetStorage: Use Rsync.
Setup Instructions:
-
Access Storage Group Details
From your Storage Group details, locate the rsync domain name. -
Note Down Domain Name
Example:1fe.rsync.upload.akamai.com
Record this domain as you’ll use it in upload commands. -
Navigate to Security Settings
Go to the Access & Security tab in your Storage Group. -
Configure SSH Key
Retrieve or generate your NetStorage SSH key. -
Set Key Permissions
Ensure the key file has proper permissions (chmod 600
). -
Store Key Securely
Store the key securely for CI/CD use. For guidance on adding secrets to your CI/CD pipeline, see the Secrets Management section.
Official Documentation: Uploading Content to NetStorage
Step 4: Configure an Akamai CDN Property
The final step is to create a CDN property to serve content from your NetStorage origin.
Setup Instructions:
-
Navigate to Property Manager
Go to Akamai > CDN > Property Manager in the Akamai Control Center. -
Start New Property Creation
Click Create a New Property to start the setup process. -
Select Product and Contract
Choose the appropriate product and contract for your property. -
Add Hostname
Add the Hostname for accessing your content (e.g.,assets.yourdomain.com
). -
Verify Domain Control
Ensure the domain is under your control and DNS can be configured. -
Locate Origin Server Behavior
Find the Origin Server behavior in the Default Rule. -
Set Origin Type
Set Origin Type toNetStorage
. -
Select CP Code
Select the CP Code you saved from Step 2. -
Verify Origin Hostname
The Origin Hostname will automatically populate based on your NetStorage configuration. -
Configure Caching Rules
Set up caching rules for optimal performance and efficiency. -
Set Up SSL Certificate
Configure SSL certificate for HTTPS support (required for production). -
Configure Security Headers
Add security headers and CORS settings as needed for your application. -
Enable Compression
Configure compression and optimization settings. -
Activate on Staging
First: Activate the property on the staging network for testing. -
Test and Verify
Test: Verify content delivery, functionality, and performance
Monitor: Check edge cache behavior and response times. -
Deploy to Production
Finally: Activate on the production network when validation is complete.
Official Documentation:
CI/CD Integration
Automated Deployment with Akamai
CI/CD Integration:
For complete, production-ready CI/CD workflows and deployment automation, refer to our dedicated repositories:
- 1fe-ci-cd Repository - Complete GitHub Actions workflows, deployment scripts, and automation templates
- Akamai Upload Action - Specific GitHub Action for uploading widget files to Akamai CDN
- mock-cdn-assets Repository - Example asset structures, directory layouts, and configuration files
Deployment Strategy
Environment Management:
We have setup two environments for our CDN:
- Integration environment:
integration/
- For testing new features and integration testing - Production environment:
production/
- For live user-facing deployments
Additional Resources
1fe Implementation Resources
- 1fe-ci-cd Repository - Complete CI/CD workflows and deployment automation
- mock-cdn-assets Repository - Example asset structures and configurations
Akamai Resources
- Akamai Control Center - Main management interface
- Akamai Developer Portal - APIs and automation tools
- Akamai CLI - Command-line interface for automation
- NetStorage API Documentation - For automated uploads and management
Alternative CDN Providers
While this guide focuses on Akamai CDN setup, you can use other CDN providers for hosting your 1fe widget bundles:
Cloud Provider CDNs:
- Amazon CloudFront (AWS)
- Azure CDN
- Google Cloud CDN
Modern CDN Services:
- Cloudflare
- Fastly
- KeyCDN
Specialized Solutions:
- JSDelivr
- UnPkg
Next Steps
After setting up your CDN: