[Django] #28764: Store staticfiles.json with code

27 views
Skip to first unread message

Django

unread,
Nov 2, 2017, 7:54:45 AM11/2/17
to django-...@googlegroups.com
#28764: Store staticfiles.json with code
-------------------------------------+-------------------------------------
Reporter: Kevin | Owner: nobody
Christopher Henry |
Type: | Status: new
Uncategorized |
Component: | Version: 1.11
contrib.staticfiles |
Severity: Normal | Keywords:
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
When you run `collectstatic` with the `ManifestStaticFilesStorage`
backend, it creates a mapping from raw filenames to versioned filenames
and stores it in a file called `staticfiles.json` alongside the static
files. My suggestion is to store that file with the code instead.

The static directory is a strange place for it, since it is not itself a
static file, nor does it have anything to do with serving static files.
What it is is a configuration file that affects what Django inserts into
dynamically-generated pages. It has more in common with `settings.py` than
a static file.

Now, that hardly matters in a traditional deployment where static files
are served from the same machine as Django; it's just one directory versus
another. However, this approach has some serious drawbacks in the common
deployment scenario of hosting the static files separately (from S3, for
example).

One problem is that Django has to fetch a remote file as part of its
startup. That has a performance penalty, places limits on the server, and
adds an additional point of failure. More seriously, it can actually break
your site during deployment. Fundamentally this is because the generated
mapping is correct only for the commit that produced it, but it's being
uploaded to a global location where it affects the behavior of all extant
servers. So any servers that are running (or restarted) between the time
`collectstatic` is run and when the new code is fully rolled out can
behave incorrectly.

For an example of this problem in the field, see
[https://devblog.kogan.com/blog/a-hidden-gem-in-
django-1-7-manifeststaticfilesstorage this blog post]. As noted there,
it's possible to change the manifest location by supplying your own custom
storage backend. My suggestion would be to change this in Django itself,
though, since I don't see the advantage of the current behavior.

--
Ticket URL: <https://code.djangoproject.com/ticket/28764>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Nov 2, 2017, 7:55:32 AM11/2/17
to django-...@googlegroups.com
#28764: Store staticfiles.json with code
-------------------------------------+-------------------------------------
Reporter: Kevin Christopher | Owner: nobody
Henry |
Type: Uncategorized | Status: new
Component: contrib.staticfiles | Version: 1.11
Severity: Normal | Resolution:
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Kevin Christopher Henry):

Related: #27541.

--
Ticket URL: <https://code.djangoproject.com/ticket/28764#comment:1>

Django

unread,
Nov 2, 2017, 9:13:29 AM11/2/17
to django-...@googlegroups.com
#28764: Store staticfiles.json with code
-------------------------------------+-------------------------------------
Reporter: Kevin Christopher | Owner: nobody
Henry |
Type: | Status: new
Cleanup/optimization |

Component: contrib.staticfiles | Version: 1.11
Severity: Normal | Resolution:
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Tim Graham):

* type: Uncategorized => Cleanup/optimization


Comment:

Duplicate of #27590?

--
Ticket URL: <https://code.djangoproject.com/ticket/28764#comment:2>

Django

unread,
Nov 3, 2017, 5:57:53 AM11/3/17
to django-...@googlegroups.com
#28764: Store staticfiles.json with code
-------------------------------------+-------------------------------------
Reporter: Kevin Christopher | Owner: nobody
Henry |
Type: | Status: new
Cleanup/optimization |
Component: contrib.staticfiles | Version: 1.11
Severity: Normal | Resolution:
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Kevin Christopher Henry):

Interesting, I didn't see that one. I'll add a comment over there...

--
Ticket URL: <https://code.djangoproject.com/ticket/28764#comment:3>

Django

unread,
Nov 4, 2017, 10:19:43 AM11/4/17
to django-...@googlegroups.com
#28764: Store staticfiles.json with code
-------------------------------------+-------------------------------------
Reporter: Kevin Christopher | Owner: nobody
Henry |
Type: | Status: closed

Cleanup/optimization |
Component: contrib.staticfiles | Version: 1.11
Severity: Normal | Resolution: duplicate
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Tim Graham):

* status: new => closed
* resolution: => duplicate


--
Ticket URL: <https://code.djangoproject.com/ticket/28764#comment:4>

Reply all
Reply to author
Forward
0 new messages