Opened 10 years ago

Last modified 12 months ago

#27929 assigned New feature

Add ManifestStaticFilesStorage option to remove original (non-hashed) files after processing

Reported by: Jesse Owned by: blighj
Component: contrib.staticfiles Version: 1.10
Severity: Normal Keywords:
Cc: Ed Morley Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: yes
Easy pickings: no UI/UX: no

Description

When collecting statics with CachedStaticFilesStorage or ManifestStaticFilesStorage, hashed versions of the files are created along side the originals. The documentation ​specifically states that this is intended to support any old links which point to the original non-cached versions of the files. However, for a new project, it's perfectly reasonable to not want to generate both sets of static files once your project is being served on a production server.

Change History (10)

comment:1 by Tim Graham, 10 years ago

Triage Stage: Unreviewed → Accepted

I think it's okay, see ticket:24452#comment:17 and subsequent comments for possibly related discussion.

in reply to:  1 comment:2 by Ed Morley, 9 years ago

Cc: Ed Morley added

I agree an option to remove the original files would be great.

Replying to Tim Graham:

I think it's okay, see ticket:24452#comment:17 and subsequent comments for possibly related discussion.

So I think those comments were more about the intermediate files left behind (eg foo.<intermediate-hash>.css) rather than the original files (eg foo.css). For fixing the former there's ticket #28604, which would likely do the right thing all the time, rather than being opt-in. However I guess the same CachedStaticFilesStorage limitation might apply to the original files too.

That said, given this feature would be opt-in, and could perhaps be made to only support ManifestStaticFilesStorage, then perhaps this feature could be added even before #28606 / #28604?

Fwiw, WhiteNoise rolls its own implementation to remove them currently:
​https://github.com/evansd/whitenoise/blob/9d3ad51f7f05e5391ec6f2f03211d958a08e374f/whitenoise/storage.py#L32

...though I'm likely going to be revising it slightly to be more like:
​https://github.com/moccu/barbeque/blob/dc714b4fa7ce2ad517a0d37474f8a774df46219c/barbeque/staticfiles/storage.py#L16-L17

comment:3 by Ed Morley, 9 years ago

Summary: Add an option when collecting statics to remove non-cached files after processing → Add ManifestStaticFilesStorage option to remove original (non-hashed) files after processing

comment:4 by valleyofblackpanther, 4 years ago

Is this ticket still active?

comment:5 by valleyofblackpanther, 4 years ago

Has patch: set
Resolution: → fixed
Status: new → closed
Triage Stage: Accepted → Ready for checkin

comment:6 by Claude Paroz, 4 years ago

Needs tests: set
Resolution: fixed
Status: closed → new
Triage Stage: Ready for checkin → Accepted

Thanks for the patch! However a ticket is fixed when the pull request is committed to main. And the Ready for checkin flag should only be set by a reviewer of the patch.

comment:7 by Mariusz Felisiak, 3 years ago

Needs documentation: set
Owner: changed from nobody to Umang Patel
Patch needs improvement: set
Status: new → assigned

comment:8 by blighj, 15 months ago

This package I've been working on and hoping to get feedback on, implements a solution for this ticket ​https://github.com/blighj/django-manifeststaticfiles-enhanced

comment:9 by blighj, 14 months ago

Needs documentation: unset
Needs tests: unset
Owner: changed from Umang Patel to blighj
Patch needs improvement: unset

comment:10 by blighj, 12 months ago

Patch needs improvement: set

After talking with others at ​Django on the Med 🏖️, this patch could be better handled at the collectstatic level. Taking it out of the review queue, while I rework it.

Note: See TracTickets for help on using tickets.
Back to Top