Deprecating CachedStaticFilesStorage in Django 2.0

216 views
Skip to first unread message

emo...@mozilla.com

unread,
Sep 15, 2017, 12:58:44 PM9/15/17
to Django developers (Contributions to Django itself)
Hi!

Currently when using `ManifestStaticFilesStorage`, collectstatic generates duplicate versions of some files. For example looking at the output for contrib.admin for Django 1.11.5, there is:
- admin/css/base.css
- admin/css/base.5af66c1b1797.css
- admin/css/base.6b517d0d5813.css
- admin/css/base.31652d31b392.css

This is exacerbated when using something like WhiteNoise's CompressedStaticFilesMixin, which then has to spend extra time generating gzip and Brotli compressed versions of every file (or else try and work around it).

I was going to file a ticket about fixing this, however it appears to be unavoidable/working as intended according to:

In that ticket and corresponding PR, it's mentioned several times that CachedStaticFilesStorage is suboptimal and should probably be removed, and if that occurred it would then be possible to avoid the duplication.

As such, I'd like to propose that `CachedStaticFilesStorage` be marked as deprecated for the Django 2.0 release (with the warning suggesting people use `ManifestStaticFilesStorage` instead), so we could then remove it and make these optimisations in Django 3.0.

Thoughts?

Many thanks,

Ed

Adam Johnson

unread,
Sep 15, 2017, 1:27:26 PM9/15/17
to django-d...@googlegroups.com
(For some reason GMail is clipping your message before any content, I only saw '... [Message clipped]' and had to click to see it all)

I'm not that familiar with the static file storages, but it seems to me like it's not going to be that controversial deprecate it in order to save this duplication. The docs do read:

CachedStaticFilesStorage isn’t recommended – in almost all cases ManifestStaticFilesStorage is a better choice.

--
You received this message because you are subscribed to the Google Groups "Django developers (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-developers+unsubscribe@googlegroups.com.
To post to this group, send email to django-developers@googlegroups.com.
Visit this group at https://groups.google.com/group/django-developers.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/b5a12c9b-ab4b-4431-b633-43a0ddfdd534%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Adam

Tim Graham

unread,
Sep 15, 2017, 1:36:35 PM9/15/17
to Django developers (Contributions to Django itself)
About the timing, it's too late to get this in to Django 2.0 as the feature freeze is on Monday and I already have a large queue of review work to do before then. I don't think it makes much difference since features deprecated in both Django 2.0 and 2.1 will be removed in Django 3.0.

Ed Morley

unread,
Sep 18, 2017, 6:47:02 AM9/18/17
to django-d...@googlegroups.com
On 15 September 2017 at 18:26, Adam Johnson <m...@adamj.eu> wrote:
(For some reason GMail is clipping your message before any content, I only saw '... [Message clipped]' and had to click to see it all)

This must be due to using the Google Groups interface for posting - I'll stick to email from now on :-)

On 15 September 2017 at 18:36, Tim Graham <timog...@gmail.com> wrote:
About the timing, it's too late to get this in to Django 2.0 as the feature freeze is on Monday and I already have a large queue of review work to do before then. I don't think it makes much difference since features deprecated in both Django 2.0 and 2.1 will be removed in Django 3.0.

Ah ok - I didn't realise features deprecated in Django 2.0 and 2.1 would both be eligible for removal at the same time; re-reading the deprecation policy [1] I see now it's only Django 2.2 deprecations that would get deferred to Django 3.1.

Given it sounds like this deprecation might be feasible, I've filed a ticket for doing so in Django 2.1:

And another for making ManifestStaticFilesStorage not leave the intermediate files behind:

Many thanks,

Ed

Tim Graham

unread,
Jan 15, 2018, 10:13:22 AM1/15/18
to Django developers (Contributions to Django itself)
The documentation says that CachedStaticFilesStorage "is mostly useful for situations in which you don't have access to the file system." What should be used for that situation if CachedStaticFilesStorage is removed?


On Friday, September 15, 2017 at 12:58:44 PM UTC-4, emo...@mozilla.com wrote:

Kevin Christopher Henry

unread,
Jan 18, 2018, 7:46:58 AM1/18/18
to Django developers (Contributions to Django itself)
I believe the typical approach is to use one of several third-party packages that uses cloud storage (e.g. django-s3-storage).

Were you thinking of adding a note to the documentation? I guess the question is where to put it, since it's more of a File Storage API issue than something specific to staticfiles. Still, I suspect a lot more people look at the staticfiles documentation than the File Storage API documentation, and they are probably more likely to need the advice.

Cheers,
Kevin
Reply all
Reply to author
Forward
0 new messages