﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
33148	Set `Cache-Control: max-age=0` header on static files response so that files are easily refreshable during development	bhch	nobody	"**Problem**

Currently, the view  (`django.views.static.serve`) which serves static files in development only sets a `Last-Modified` header.

The problem this produces is that Firefox and Chrome don't send the cache revalidation requests (`If-Modified-Since` header), and will keep on serving stale files even after modifications. [https://engineering.fb.com/2017/01/26/web/this-browser-tweak-saved-60-of-requests-to-facebook/, Here's a good article on this from Facebook Engineering].

So, during development, when we make changes to the static files (CSS/JS), we need to open the `Network` tab and disable the cache to refresh the static files.

On Mobile, disabling cache is not possible so we have to test in Incognito mode.

**Solution**

Set `Cache-Control: max-age=0` header on the response.

As per [https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cache-Control#requiring_revalidation this MDN page on Cache-Control] and some tests I did on my computer, browsers can be forced to revalidate the cache using `Cache-Control: max-age=0` header.

This will force the browsers to send the `If-Modified-Since` header and Django can then send a 304 response if unmodified or serve the fresh file if modified."	Cleanup/optimization	closed	contrib.staticfiles	3.2	Normal	duplicate			Unreviewed	0	0	0	0	1	0
