[Answered ]-Django Whitenoise cache busting control

2👍

Yes, you’ll need to run collectstatic every time your files change.

It’s very unusual to have 250MB of static files. Also, because Django’s cache busting creates a copy of each file with a unique name you’ll end up with two copies of each file so that’s 500MB already. On top of this WhiteNoise will be creating gzip-compressed versions of each file so you could be heading towards 1GB of files.

One quick way of speeding up this process would be to tell WhiteNoise not to compress your PDF files, which you can do by adding .pdf to the WHITENOISE_SKIP_COMPRESS_EXTENSIONS setting.

It sounds like your brochures would be better stored as user media though, rather than static assets.

To control caching you should make your code generate a unique name for each file when it’s uploaded (adding a random string as a prefix to the filename should do the trick). You can then set caching headers on these files for as long as you like.

Leave a comment