Firstly I've tried most of the solutions suggested in Stack and from Google. None of the below solutions work when DEBUG MODE is off.
- sudo systemctl daemon-reload , sudo systemctl restart gunicorn to make sure its not a gunicorn issue
- Turned off all caching from nginx. Made sure this was the case with
curl -I "https://swjungle.shop/2static/CACHE/css/output.9291a1ea98ad.css"
returns
Cache-Control: no-cache
- Checked Nginx config again. If debug=True the static files are still not reloaded until collectstatic. But after collectstatic it works. .staticfiles is my STATIC_ROOT
location /2static {
alias /home/.staticfiles;
}
- sudo systemctl restart nginx also does not reload caching
- My browser caching is off and I did a hard reload , Ctrl + F5. Deleted all cookie.
None of it works... Struggling to find a solution.
Here is my settings.py for cache stoarge
STATICFILES_STORAGE = 'django.contrib.staticfiles.storage.ManifestStaticFilesStorage'
INSTALLED_APPS += ["compressor"]
STATICFILES_FINDERS = [
"django.contrib.staticfiles.finders.FileSystemFinder",
"django.contrib.staticfiles.finders.AppDirectoriesFinder",
"compressor.finders.CompressorFinder"
STATIC_URL = '/2static/'
STATIC_DIR = str(ROOT_DIR / "2static")
STATICFILES_DIRS = [
STATIC_DIR,
]
STATIC_ROOT = str(ROOT_DIR / ".staticfiles")
After moving css file out of compress block - hashed css file is created in .staticfiles but browser still searches for the old hash css file DIR of CSS