Local server not reflecting updated files

别等时光非礼了梦想. 提交于 2019-12-05 16:17:57

问题


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 I'm using in the game, and I sometimes update these assets. When I do, the changes to the images aren't reflected in the game. I've tried restarting the server but that doesn't help. It usually takes some time for them to update, maybe about an hour. Any ideas what's going wrong?


回答1:


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'.




回答2:


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)




回答3:


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

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




回答4:


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.



来源:https://stackoverflow.com/questions/29105729/local-server-not-reflecting-updated-files

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!