- Django 3 Web Development Cookbook
- Aidas Bendoraitis Jake Kronika
- 101字
- 2025-04-04 13:15:07
Setting up STATIC_URL dynamically
If you set STATIC_URL to a static value, then each time you update a CSS file, a JavaScript file, or an image, you and your website visitors will need to clear the browser cache in order to see the changes. There is a trick to work around clearing the browser's cache. It is to have the timestamp of the latest changes shown in STATIC_URL. Whenever the code is updated, the visitor's browser will force the loading of all new static files.
In this recipe, we will see how to put a timestamp in STATIC_URL for Git users.