I change a CSS file, run collectstatic but nothing happens - the app keeps the previous styling, even though that CSS no longer exists anywhere in my files. I got frustrated and gave up yesterday, and found that this morning it had updated, but the initial problem persists. Has anyone else experienced this? Is it just an issue with pythonanywhere or might there be a problem in my code?
Method 1 Each time you edit your CSS file you need to either hard reset it with Shift + F5
Method 2 You have the possibility to edit the file in the index page (or wherever you load in the file in. After the .css you need to enter a query like ?q=...
So like this:
OLD FILE: <link href="/css/TestFile.css" rel="stylesheet">
After editing it to refresh the cache: <link href="/css/TestFile.css?v=1" rel="stylesheet">
v standing for version, you can use any character.
Method 3 To disable caching you'll have to look into your web.config file. There might be something similar like this:
<location path="css">
<system.webServer>
<staticContent>
<clientCache cacheControlMode="UseMaxAge" cacheControlCustom="public" cacheControlMaxAge="7.00:00:00" />
</staticContent>
</system.webServer>
Remove that and it stops caching. You might also have to look into the IIS settings but I don't know about that, read more here
Edit: Added the method text. If you have a live website with customers I would recommend using Method 2. Having caching enabled increases your website speed as they do not need to load the css, javascript, media etc etc files every time they visit your page. Only once in a while.