2

I have files index.html and style.css I want to test using a local server, which I do by running python -m http.server.

If I make a change to file style.css (i.e. a file that is not index.html), then when I reload the page I'd like to see the corresponding update. When this actually happens, on the terminal the following appears:

::ffff:127.0.0.1 - - [11/Aug/2022 09:55:24] "GET /style.css HTTP/1.1" 200 -

but this happens very inconsistently: more often than not, when I make a change to the file and reload the page, it doesn't update at all.

What can I do so that each time I reload the page, the server reloads style.css?

4 Answers4

2

You can press CTRL + F5 force browser to get data from server immediately not from browser's cache.

loeric
  • 64
  • 4
2

In your browser you could open up Inspect Element (CNTRL+SHIFT+I). Here you go to the settings icon > Preferences > Network. There is a option called Disable cache (while DevTools is open). If you enable this you should not have to manually force reload the site.

annes
  • 123
  • 1
  • 6
  • 1
    This is what I personally always use. This way you can just refresh using ctrl + R which is easier to reach on my keyboard. – Joost00719 Aug 11 '22 at 10:25
0

I'm no expert but 200 code is for succes code OK so there might be some problem saving the css file

0

Other than what others said, when programming servers with node.js I used nodemon to automatically reload it based on any change, be it code or CSS, but I still needed to reload the page.

Nonetheless, it is super handy and can also be used with python. See this answer.

DMeneses
  • 171
  • 1
  • 10