Local server not reflecting updated files

后端 未结 5 1850
感动是毒
感动是毒 2021-02-13 17:42

I\'m fairly new at user local servers. I\'m using the http-server which is a package from Node. I\'m using it to host an HTML5 game using the Phaser library. I have image assets

相关标签:
5条回答
  • 2021-02-13 18:08

    Make sure your html file is in the correct location. A couple of times I've been editing my html and js files and then at some point I might cut and paste the files into a new folder. I'll change the reference to the new directory. But I forget that I need to reopen the html and js files from the new directory. Instead I keep editing them from the old directory and refreshing the browser wondering why nothing is changing. It's because the files I'm editing are the versions in the old directory. I need to close them and then open the files that are in the new directory.

    0 讨论(0)
  • 2021-02-13 18:11

    You can disable cache in Chrome DevTools under "Network".

    Whenever you reload a page while DevTools is open, it will clear the cache.

    0 讨论(0)
  • 2021-02-13 18:13

    There's a option -c that refers to the cache time (max-age) in seconds [3600]

    (e.g. -c10 for 10 seconds).

    To disable caching, use http-server -c-1

    You can see more information by enter http-server -h (for help)

    0 讨论(0)
  • 2021-02-13 18:18

    The browser might be caching your code and/or assets.

    In Chrome, with dev tools open (Right click -> Inspect element) you can right click on the refresh button and 'empty cache and hard reload'.

    0 讨论(0)
  • 2021-02-13 18:27

    You can try to use live-server instead. It works for me.

    npm install live-server -g
    

    And you can start it simply by the command live-server.

    0 讨论(0)
提交回复
热议问题