Local server not reflecting updated files - node.js

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?

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

There's an 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)

You can disable cache in Chrome DevTools under "Network".
Whenever you reload a page while DevTools is open, it will clear the cache.
Alternatively, use the hard refresh keyboard shortcut (Mac):
CMD+shift+r

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.

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.

Related

I've accidentally used browser-sync without going to the local folder

Am I in trouble?
I've very new to code and just learning how to update my repository or something on github.
Anyway, I went and tried to use browser-sync and used the following command:
browser-sync start -- server -- directory --files "*"
only for my firewall to prompt me about blocking some features of the program nodejs. Like it said from a video, a tab was made on chrome but instead of some specific folder, it showed ALL my folders in my local user like the the Documents, Pictures, Downloads etc. I think this was because I didn't cd to the specific folder I want to show
My pc is new so there really wasn't much in it but I'm scared I may have compromised my security. In panic, just exited both the firewall prompt and the tab so I wasn't able to snip it.
I don't know if I left some vital info out but that's just it. What should I do? I don't care much about my files but I've saved some of my passwords on chrome (social media sites, mostly. Few about my job. Nothing on payments) . Should I just change all of them? What are the steps I should do?

Python3 web-server: Difference between localhost and 127.0.0.1?

I'm creating a local web-server in python for web-page testing purposes. While testing the web-page, I get two different results depending on whether I open localhost:8000/index.html or 127.0.0.1:8000/index.html in the web-browser (Chrome).
In the first case, it pulls an older version of the index.js file (from like days-ago old); but the 127.0.0.1 version pulls the correct file. So why would I be getting two different javascript files depending on the source when both are technically from the same directory? Where might I find the days-old file at?
I run the server from the html directory using the command:
python3 test_server.py
Index.html, Index.css, Index.js and test_server.py are the only files located in the directory...
Thanks,
So this is a caching issue. The Python webserver is not even requesting the new js file from a couple days ago was pulled on localhost Whereas the one on 127.0.0.1 was either expired or never pulled, so chrome pulled a new one.
To do a hard pull in chrome, right mouse click and then click on inspect. This opens the dev tools. Now right mouse click on the refresh page button and click on 'Hard Reload'. This will tell chrome to disregard any cached files and instead pull them from the server.
To avoid having to do this each time:
Click on the network tab in the devtools and make sure the box disable cache is checked.
However, be aware this will slow down load times on other sites, because no site will use caching with that box checked. So make sure you uncheck it when you are done doing dev work.

User Control location and update during development

I have an user control, with name Test1 for example, in the directory:
C:\Models...\CSharpModel\web\Test1
Even when I delete it in that directory, the user control still works in the webpanel on the browser. Why this happens? How can I make sure the user control is deleted?
And how can I make sure the user control is updated? Because even when I change the version, do the install command, restart the browser and make sure the browser is refreshed properly (or test it in another browser), sometimes I don't get the lasted changes that I have made in the javascript code.
Must increase the version number <Version>X.X</Version> located in YourUserControl.control. This is how GeneXus knows if the UC was updated.
Close GeneXus.
After updating any file within a usercontrol, you have to copy those files to your GeneXus Installation Folder/UserControls.
Run Genexus.exe /install
Run GeneXus
Build All (GeneXus will detect version change in your UC and automatically copy UC files)

OwnCloud Remove all files prompt

I have a owncloud server and the owncloud desktop client.What I want to do is to be able to delete things server wise and have it automatically delete from the pc. The problem is that the owncloud client displays a warning message of "Remove All Files"? with the choices of Remove all files or to keep files when the files are deleted from the server. Is there a way to not have the prompt come up and automatically remove all files?
In the version 2.2.3 (maybe earlier), you can change the configuration file to disable the prompt.
See the code where the prompt is invoked and the code showing the configuration file property.
If you edit (on Windows): c:\Users\myuser\AppData\Owncloud\owncloud.cfg and add the following, under the [General] section, you will no longer get the prompt.
promptDeleteAllFiles=false
The short answer: You cannot change this currently.
The long answer: The dialog was added as a safe-guard because there were cases where you could lose all your files unintentionally, e.g. if your admin re-created your account and left it empty. The client would assume the files had gone and would replicate this (it could not know better), so it would replicate the data removal locally. The code is still there today just to be safe.
If you are fearless, you can patch Folder::slotAboutToRemoveAllFiles(). Alternatively, you could open a bug report so we can solve this for everyone. What is your motivation to be able to do this without a prompt?
PS: The sources can be found on GitHub. URL and build instructions at http://doc.owncloud.org/desktop/1.5/building.html.
I have a script that processes the files that someone drops into ownCloud and it will then move them to the final storage place. However, this prompt stops the client from syncing until I manually log in to acknowledge it... I guess I will learn how to patch this.. Dropbox doesn't do this. Google Drive doesn't do this. But since I can't use cloud services (compliance issues), I have to use this solution until I can build a new secure upload means.

Cyberduck uploads break node-dev/up/hotnode

I've been using Cyberduck 4.2.1 to connect to my EC2 instance to edit my Node projects. I've used Node-dev to reload my project/server as files are updated, but if I save the files through Cyberduck's Edit command, the server never really reloads and usually crashes.
I've tested with a few different editors (TextMate, Dashcode) with the same result. Node-dev restarts correctly when I edit files from the terminal. I have tried a few others that do rougly the same thing, hotnode and up. They all work when editing via Terminal, but fail when I edit files through Cyberduck. I think it has something to do with the way Cyberduck replaces the remote files when it is saved.
Does anyone know what might be causing this, and maybe suggest some changes to these github projects? If not, are there better Mac FTP clients that might not have this issue?
I don't know about Node-dev, but my educated guess is that it crashes because it reads a partially uploaded file. I suggest to try the Upload with temporary filename feature available as a hidden option in Cyberduck.
You can try CyberDuck 6.6.2 ....It works for me

Resources