CSS Static Files Not Updating After Successful Deployment

leolmz59
HOBBYOP

6 months ago

Hi Railway Team,

I'm experiencing an issue with my Django application deployed on Railway where CSS changes are not being reflected on the live site, even after successful deployments and clearing browser caches.

Project Setup:

Framework: Django

Static Files Serving: Whitenoise (whitenoise.middleware.WhiteNoiseMiddleware and whitenoise.storage.CompressedManifestStaticFilesStorage are configured)

Build Method: [Specify if using Buildpacks/Nixpacks OR a Dockerfile]

Repository Structure: Standard Django layout with manage.py, Procfile, requirements.txt in the root. settings.py/wsgi.py are in comparaplan/comparaplan/. Static source files are intended to be in comparaplan/static/.

Railway Root Directory Setting: / (Repository Root)

Deployment Process & What Works:

Builds complete successfully.

The Pre-deploy Command is set to: python manage.py migrate && python manage.py collectstatic --noinput --clear

The deployment logs clearly show both migrate and collectstatic running successfully during the pre-deploy phase. collectstatic reports copying files (e.g., XXX static files copied to '/app/staticfiles').

The Start Command is set to: gunicorn comparaplan.comparaplan.wsgi --bind 0.0.0.0:$PORT --log-file - (or it's correctly defined in the Procfile and the start command field is empty).

The runtime logs show Gunicorn starting successfully and listening on the correct port.

The application loads without 5xx errors.

The Problem:

Despite the above, CSS changes made to files (specifically tested with comparaplan/static/styles/global.css) are not visible on the deployed site.

Troubleshooting Steps Taken:

Confirmed CSS changes were committed and pushed to the correct branch (main) before deployment.

Verified collectstatic runs successfully in the pre-deploy logs (including using the --clear flag).

Verified settings.py:

DEBUG = False

STATIC_URL = 'static/'

STATIC_ROOT = BASE_DIR / 'staticfiles'

STATICFILES_DIRS = [ BASE_DIR / 'static' ] (where BASE_DIR points to the comparaplan directory containing manage.py)

STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage'

whitenoise.middleware.WhiteNoiseMiddleware is present.

Cleared browser cache multiple times (simple clear, hard refresh Ctrl+Shift+R, incognito window).

Used browser Developer Tools (Network tab, "Disable cache" checked) to inspect the response for the CSS file (e.g., global.[hash].css). The content shown in the "Response" tab is the OLD version of the CSS, not the newly committed changes.

Request:

Could you please help investigate why the updated static files, specifically comparaplan/static/styles/global.css, are not being served despite collectstatic appearing to run correctly during the pre-deploy phase? It seems like Whitenoise might be serving files from an older staticfiles directory, or the collectstatic process isn't correctly updating the files despite the logs indicating success.

My Project ID is: [Your Project ID]

The relevant web service name is: [Your Service Name]

Please let me know if you need any further information or access to logs.

Thanks for your help!

Best regards,

Closed

1 Replies

6 months ago

Hey!

This is an issue with your project/application. Unfortunately, we're unable to offer first-party support for issues unrelated to the Railway product or platform.

Other communities such as Stackoverflow might be able to help you out further.

Best,
Brody


Status changed to Awaiting User Response Railway 6 months ago


Status changed to Closed brody 6 months ago


Loading...
CSS Static Files Not Updating After Successful Deployment - Railway Help Station