I'm having a css file and i want to modify it to fit my needs. The problem is that it seems to be cached somewhere, as i just cannot see the changes, no matter what i do in the css file. I am sure i am pointing to the right file, as by now i'v modified in it, and it worked. Is there any setting so that i can turn the cache off? Thanks!
4 Answers
As pointed out in this article http://www.wkoorts.com/wkblog/2009/07/12/css-auto-reload-with-django-templates/, you could force django reload your css file by using a parameter in your css link :
<link rel="stylesheet" type="text/css" href="/site_media/css/style.css?{% now "U" %}" />
This is a timestamp which takes a different value every second, so you could even reload your css second every second if needed!
1 Comment
.../style.css?version=1 and increment the version every time you make a changeDid you try appending a datetime stamp to the end of the request? I know some frameworks do this to .js and .css files automatically to prevent caching.
1 Comment
Instead of using complicated solutions you can add extra parameter to your includes in the templates.
For static includes:
<script src="{% static 'js/polls/polls.js' %}?version=1"></script>
For direct includes:
<link rel="stylesheet" type="text/css" href="/site_media/css/style.css?version=1" />
Note the ?version=1 in the code. Every time you're modifying the file, change this version in the template, so browser will be forced to reload the file.
Of course you can use even now as suggested by @rom, but if your static files are not being changed very often, it's not the smartest idea to don't use cache at all.