2

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?

4
  • 1
    Do you have caching enabled? Sounds like the server is caching the CSS file. Shift + F5 should remove the caching but doesn't solve for everyone as this solution is individual. If you got caching enabled let me know. Commented Nov 8, 2017 at 9:37
  • You have to hard reset you browser with CTRL + SHIFT + R, in order to clear your cache. Commented Nov 8, 2017 at 10:16
  • @Mik3NL this worked, thanks :) Do I have to do this every time or is there a way to disable caching? Commented Nov 9, 2017 at 11:00
  • I posted an answer for you, hope this helps out. Commented Nov 9, 2017 at 11:07

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.