whitenoise icon indicating copy to clipboard operation
whitenoise copied to clipboard

Big picture like this?

Open guettli opened this issue 5 years ago • 3 comments

I heard that whitenoise is great at several places.

But somehow I don't get the big picture.

Could you please make this more newcomer friendly by adding how a http-request gets handled step by step in a default installation?

If I understood it correctly it works like this (if you use gunicorn to run the django application):

First request:

  1. browser sends http request to https://example.com/static/foo.css
  2. The proxy at https://example.com does not know the file foo.css yet, it forwards the request to a gunicorn process.
  3. The WhiteNoiseMiddleware processes the requests, sends the foo.css to the proxy and sets http-headers telling the proxy to cache the file
  4. the proxy forwards the response to the browser.

A second request (coming from a second browser or not):

  1. browser sends http request to https://example.com/static/foo.css
  2. The proxy at https://example.com does know the file foo.css, and sends the cached version to the browser. The gunicorn application is not touched.

It would be nice to have these step at the top of the docs to make it easier to understand.

guettli avatar Dec 17 '20 21:12 guettli

Yes, that's exactly how it works. I agree an overview like this would be a nice to thing to have in the docs. If I ever get time I'll add it!

evansd avatar Dec 18 '20 10:12 evansd

Some concrete examples might be useful but I think it makes sense that the current description focuses on setting http headers mainly. Also, I guess you'd rephrase this a bit anyway, but I'd just note that using gunicorn and a caching proxy might be common but neither of those are required.

balazs-endresz avatar Dec 20 '20 13:12 balazs-endresz

@evansd Is there anything we can do to help you, to get a step-by-step introduction like above?

guettli avatar Jul 21 '21 14:07 guettli