0

When we are doing changes in the code of CSS or python Django, sometimes the changes are reflecting after 15-20 min. but when we restart the web server the changes reflect. so is there any setting in Django to store or release Cache Memory or Virtual Memory that is making the code changes response slower?

Adrian Klaver
  • 15,886
  • 2
  • 17
  • 28
  • 1
    Browsers have a hard refresh option, why not use them ctrl + F5 should work. But if you really need to not use caching check [this](https://docs.djangoproject.com/en/3.1/topics/http/decorators/#caching) – Abdul Aziz Barkat Jan 15 '21 at 15:02
  • As a clarification it's not Django or PostgreSQL that's making changes reflect slowly, your browser has cached the css files, etc. to optimize internet usage / make loading faster. – Abdul Aziz Barkat Jan 15 '21 at 15:14
  • This has nothing to do with Postgres, so I removed postgresql tag. – Adrian Klaver Jan 15 '21 at 16:14
  • Hi @AbdulAzizBarkat I tried the hard refresh option, ctrl + F5 but it didn't work, cleared the Browser cache, used a different browser, different machine but nothing worked. but after 15-20 min. the changes reflects or if I restart the server it reflects instantly. The issue occour sometime and often – Sachin Kumar Jan 15 '21 at 17:23
  • Please check [this](https://docs.djangoproject.com/en/3.1/howto/static-files/deployment/#serving-static-files-from-a-dedicated-server) link, also [this](https://stackoverflow.com/questions/27911070/django-wont-refresh-staticfiles) link might be helpful – Abdul Aziz Barkat Jan 15 '21 at 17:31

1 Answers1

0

As the commenters have mentioned, this could be a case of your webbrowser caching recent CSS files. There are two solutions for this:

  1. Hard-refresh your web browser by holding Shift while clicking the refresh button, or by typing Ctrl-F5 or Command-F5.

  2. Change the link to your CSS files by appending something inconsequential to it:

    <link rel="stylesheet" href="{% static 'main.css' %}?12345">
    

    This will ensure that others will see your updates immediately, even without hard refreshing the page.

Jaap Joris Vens
  • 3,382
  • 2
  • 26
  • 42
  • Hi Experts if anyone has any experience with the Django Memory Leak solution. Is there is any sample code example? it will be really helpful #djangomemoryleak @hedgie – Sachin Kumar Jan 18 '21 at 10:16