Is the any automated way to remove (or at least mark) unused non-used (non-referenced) files located in /static/
folder and its sub-folders in Django project?
This is not neccessery since django will pick only the updated files, and the whole idea of collectstatic is that you don't have to manually manage the static files.
However, if the old files do take a lot of space, once in while you can delete all the files and directories in the static directory, and then run collectstatic
again. Then the /static/ dir will include only the updated files.
Before you run this, check how much time does it take, and prepare for maintenance.
Note: Delete and re-create all files may still require reload of these files by the client browsers or a CDN. It depends on your specific configuration: CDN, caching headers that use the file creation dates, etc.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With