The problem: Version skew
Modern frontend build tools like Vite generate content-hashed filenames for static assets (e.g.,main-abc123.js). Each build produces unique filenames based on file contents. During deployments, this can cause a race condition:
- User loads
index.htmlwhich referencesmain-abc123.js - New deployment replaces containers with a new build
- New containers only serve
main-xyz789.js(new build) - User’s browser requests
main-abc123.jsfrom cached HTML - Request returns 404 — the old asset no longer exists
This is a documented limitation in Vite’s official guidance: Load Error Handling
Current behavior
Infisical includes a built-in workaround that detects version mismatches and triggers a page reload. While functional, this introduces a noticeable delay for users during deployments.The solution: External asset storage
The solution is to store static assets externally (e.g., S3, GCS, Azure Blob) and serve them through a CDN (e.g., CloudFront, Cloud CDN, Cloudflare). Assets are uploaded before container deployment, ensuring old versions remain available.How it works
The key points:- Asset persistence: Old assets remain available even after new deployments
- Deployment order: Upload new assets before deploying new containers
- Long cache TTL: Content-hashed files can be cached indefinitely (we recommend 30 days)
- Automatic cleanup: Configure lifecycle rules to expire old assets after 30 days
Exporting assets
Infisical provides a built-in command to export frontend assets from the Docker image:What gets exported
The command exports the/assets directory containing:
- JavaScript bundles (e.g.,
main-abc123.js,chunk-def456.js) - CSS files (e.g.,
styles-789xyz.css) - Other static assets with content hashes
Integration with your pipeline
The general deployment flow should be:- Build your new Docker image (or pull the official Infisical image)
- Export assets using
npm run assets:export - Upload assets to your object storage
- Deploy the new container version