2 months ago
I'm experiencing an issue where JavaScript files in my /public/js/ directory aren't updating after deployment, even though Railway shows "Deployment successful."
What I've tried:
Multiple deployments (all show successful)
Cache-busting query parameters (
?v=2,?v=3)Manual redeploy from dashboard
Testing in private/incognito mode
Verified changes exist in GitHub repo
Result: Railway continues serving old JS file versions despite successful deployments.
Is there a static file cache or CDN layer that needs manual clearing? How can I force Railway to serve the latest versions of static files?
2 Replies
2 months ago
railway doesn't cache anything on their end, your js files might not be deploying at all
try to add a test endpoint to your server that lists files in /public/js/ and check what's actually there in the container. bet the new files aren't making it into the deployment
if using railway.json with rootDirectory set, make sure /public is inside that directory. otherwise railway isn't deploying those files at all
also try hard refresh (ctrl+shift+r) but i'm sure your files just aren't in the deployed container
2 months ago
I’ve just replicated this exact ghost deployment issue.
If cache-busting (?v=2) and Incognito aren’t fixing it, then this is not a CDN or browser cache problem.
This is a deployment pipeline mismatch.
What’s actually happening
Railway saying “Deployment successful” only means the build command didn’t crash.
It does not mean your app is serving the new files.
Two usual culprits.
1) Path mismatch (very common)
Your framework (Vite / Next / Webpack) is probably building to: /dist but your runtime is still serving: /public , So the build runs and Railway reports a success, but the Old Js will keep being served, because your runtime just never touches the new artifacts.
2) Stale Nixpacks layer
Even when paths are correct, Nixpacks can reuse a cached layer that already contains old static files.
So the build runs, but the runtime keeps serving yesterday’s JS.
That’s the “ghost” part.
Fix
1) Align your Scripts: Check your package.json - Your start command must serve the build output directory, not source files. If build - dist, then start must serve dist.
2) In Railway - Service - Variables, add: NIXPACKS_NO_CACHE = 1 , this forces a clean build. No reused layers. No ghosts.
3) Redploy - Should fix it, that's all (Worked when I tested it.)