#32891: runserver serve static files cached in debug
-------------------------------------+-------------------------------------
     Reporter:  TZanke               |                    Owner:  TZanke
         Type:  Bug                  |                   Status:  closed
    Component:  contrib.staticfiles  |                  Version:  3.2
     Severity:  Normal               |               Resolution:  wontfix
     Keywords:                       |             Triage Stage:
                                     |  Unreviewed
    Has patch:  1                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  1                    |                    UI/UX:  0
-------------------------------------+-------------------------------------

Comment (by Ole Laursen):

 I just ran into this ticket - I have the reverse problem, I'd like the
 static serve to send out a cache forever header, since I have a cache
 buster in place (it appends ?_=[timestamp of file] to all references to
 static assets). So it would be nice if I could get rid of the HTTP spam
 from the 304s.

 Perhaps a compromise could be a relatively easy way of setting the static
 cache headers? Like:

 {{{
     re_path(r'^static/(?P<path>.*)$', django.views.static.serve,
 {'document_root': settings.STATIC_ROOT, 'cache_control': {'no_store':True,
 'max_age': 0}}),
 }}}

 I'm currently using a wrapper like this:

 {{{
 def static_serve_with_forever_cache(request, *args, **kwargs):
     response = django.views.static.serve(request, *args, **kwargs)
     if '_' in request.GET:
         patch_cache_control(response, public=True, max_age=365 * 24 * 60 *
 60, immutable=True)
     return response
 }}}

 So it's not a big deal. But it is somewhat of a foot gun, so explicit
 support with a little note in the documentation might be useful?

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

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/064.36e291c4e7f9b30ce64e3931ba9ef5a0%40djangoproject.com.

Reply via email to