Closed Bug 1139606 Opened 10 years ago Closed 9 years ago

Changes to assets referenced by CSS may not update due to CSS filename not updating

Categories

(www.mozilla.org :: Bedrock, defect)

Production
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED WONTFIX

People

(Reporter: pmac, Unassigned)

References

Details

(Whiteboard: [kb=1681476])

It seems that the system that creates the immutable file names for static assets (e.g. logo.a4d086593854.png) does so before the CSS files are updated to refer to said immutable file names for referenced assets (images, fonts, etc.). So a change to a static asset means a new name for said asset, but not a new CSS file name, thus no update of the CSS happens on the CDN and the new asset is never used. What needs to happen is: 1. Rename all non CSS files to new immutable file names. 2. Update CSS files to refer to the immutable file names. 3. Rename the CSS files to immutable file names based on contents that refer to the immutable files from step 1. Unless we do things in this order the hashed names of the CSS files won't accurately refer to the file contents.
I created a test project using Django 1.6.10 and 1.7.5, both with using Pipeline and without. I tested by: 1. Create a simple CSS file that refered to an image via url('/media/img/test.jpg'); 2. Create media/img/test.jpg and add dummy content. 3. Call ./manage.py collectstatic 4. Observe hashed file names. 5. Change content of media/img/test.jpg 6. Call ./manage.py collectstatic 7. Observe that no new CSS file was created (same hash), but file contents were updated to refer to new image name. So the issue is that while the CSS file's contents are updated to refer to the updated image, the hashed file name of the CSS file was not updated to reflect the content change, thus the cache of the css file would not be updated. I will be filing a bug with Django about this and will update here with progress. For now we should cache bust CSS files ourselves by affecting a small innocuous change to the CSS whenever the only thing changing is an image referred to by the file.
Whiteboard: [kb=1681476]
I've filed a bug with the Django project: https://code.djangoproject.com/ticket/24452#ticket I'll be working on a fix for bedrock, and also hopefully submitting a PR to fix this in Django as well.
Thanks for following up on this one, Pmac.
Status: NEW → RESOLVED
Closed: 9 years ago
Resolution: --- → WONTFIX
You need to log in before you can comment on or make changes to this bug.