localhost serving old file saves - angularjs

First, I apologize that I don't fully understand what's going on here. I am new to AngularJS and I am building an app that I am running on localhost:3000. I make changes to my files, and I refresh the localhost:3000 page.
But after a few times of doing this, my changes do not get passed to the server.
Upon inspecting the developer tools, I see that it is using an older version of the file that I have overwritten with new code. No matter how many times I refresh the page, the changes do not get passed to the server.
If I come back after a few hours, it gets all the changes like it should. But only the first time, because every time after that I have the same problem.
I've tried restarting the http-server, I've tried closing and opening the editor, closing and opening the tab, restarting my computer, but none of these fixes the problem permanently.
If you need any more information, I'll edit it into this question. Thanks!

Try clearing your browser cache
Either
ctrl + f5
or
Right click on refresh button and choose the last option (hard reload)
(only in chrome, I guess)

That's almost certainly a caching issue.
You need to look at the network traffic when the page is downloading.
How you do that will depend on the browser you use, but try pressing F12 for a start
Check the RESPONSE headers for anything "cache"
Also check for a Status code of 304 - "Not Modified"
That might reveal to you instructions from the server to the browser to cache the file for a few hours, or that the browser is being told the copy it has is up to date.
Alternatively it might be server side caching, in which case I can't help you much.
One other solution is to change the file reference to include the date modified as a query string.
e.g.
instead of
src="/scripts/myscript.js"
use
src="/scripts/myscript.js?dt={filemodifieddateformyscripts.js}"

Related

React sometimes not using updated source files

Usually when I make a change in a source code file the server automatically updates. Though occasionally it does not, even if I reload the page, or even close the tab and load fresh from a new blank browser tab. I have to restart the server to finally see the change. I found this out upon changing a console.log message.
Is there a way to ensure that the server is using all of the latest source files without having to restart the server? (ya as I already mentioned usually it does this automatically, but at times it does not.)

Showing failed re-building development npm/react/gatsy errors in browser

I'm doing development work using gatsby develop. Basically, this script monitors the source code files and re-builds whenever there are changes.
When the re-build succeeds, the browser automatically refreshes and shows the newly built page.
However, when the re-build fails, the browser does nothing, and if I were to manually refresh the webpage, it still loads the last working version, leading to confusion as to why my changes are not reflected.
The only way to tell that the re-build failed is by looking at the terminal output of gatsby develop, which I often hide in order to maximize screen real estate.
Is there a way to for me to just look at the browser and code, and be able to tell that a re-build has failed? The best would be to have the errors show up in the browser, much like the javascript errors, where the re-build was successful, but the code ran into issues in the browser, i.e. TypeErrors, undefined etc.
Thank you.
After #gnujoow's comments, I did a quick check and realized that build failures already show up in the browser.
For some reason, my browser does not always refresh when there are build failures. Thanks #gnujoow

How to migrate an online angular script to local server?

Hi I'm trying to make an offline version of this page:
https://u-he.com/tools/microtuning/ the script is writtin with Angular JS how do I do that?
I saved the page control-s and copied the file to the local server I'm running.
And then I browsed the local ip. the page opened but I get repeated notes ng-repeat shows up as multiple boxes instead of 1 box that edits the same note but in different octaves.
How do I solve this problem please.
You can inspect the front-end code in your browser console. In Firefox it's in the section called "Debugger", in Chrome it's called "Sources". If you use Safari, you need to enable Developer mode first.
Once you have the appropriate view, just click on u-he.com -> tools/microtuning/ -> index
Hopefully it goes without saying that you shouldn't use large swaths of another person's code without at least giving appropriate credit, or better yet getting the developer's permission, unless there is an explicit open-source license.

Cakephp, weird performance issues

I've asked this question all over the web, but nobody has replied so far.
I have a Cake app on a live server. The problem is everything seems to be cached.
Let's say you're on the index page, hit "delete" link to delete a record, and you're redirected back to the index. The "deleted" record is still shown. If you hit the refresh button, the record is no longer shown and the flash message appears.
And it's like this all over the site.
I've disabled caching in config/core.php, sessions are pure cakephp (works the same with database and php sessions), debug is 0.
Server is PHP5.
Any idea is welcome!
What is your browser? I use Opera and I admit it doesn't manage the cache the way I'd want it to. I have to refresh, while Firefox works perfectly (or at least reload the page the way I'd expect it to while I'm debugging)
(from twitter #IvanBernat) have you tried to add meta tag for killing browser cache? use firebug and see if browser get 304 code for your file

Prevent Silverlight 3 from caching while debugging

I'm assuming the issue I'm having is related to caching. Code changes I make are not getting picked up when I debug. Most times I get served a previous version of the app. How do I prevent this from happening?
Ctrl+F5 is an easy way to refresh a page and clear the cache of that page at the same time - it may help :)
Try to add to the page that hosts Silverlight application on Page_Load:
Response.Cache.SetExpires(DateTime.Now.AddSeconds(-100));
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Append a "version" querystring to your XAP Url, something like:
http://localhost:1234/ClientBin/my_silverlight_app.xap?v=1.0.287.5361
This will trick the browser (and many web servers) to think that this is a different file. And when the cache problem appears again, increase the number.
If you then want to employ proper caching, do it on the server-side with OutputCache directives.
As far as I see, this seems to be a problem with Firefox - when I used IE8, this didn't happen to me (I realize this may open its own can of worms, but at least for debugging and testing Silverlight, IE is much better)
I have not had any issues with Silverlight assemblies getting cached - you might want to try debugging the HTTP requests that go back and forth, to see if maybe your server is instead returning incorrect information to the browser (e.g. a "not modified" response).
For general no-cache behavior, the only reliable method I have found is to turn off caching in the browser.
For IE, this has been the only reliable option - otherwise, even if proper no-cache headers are sent, certain things are still cached (specifically, dynamically loaded resources which are accessed via Javascript XmlHttpRequest). I have not specifically had issues with Silverlight getting cached when it should not, though - IE has always loaded the latest updates even if cache is enabled.
Firefox has been much more problematic - even when disabling cache, it still sometimes caches XmlHttpRequest-loaded resources. Manually hitting Refresh a few times has been the only solution in such a case. Once again, I have had no issues with Silverlight assembles, even if cache is turned on.
In Firefox, I use the 'web developer' plugin and simply select to 'disable cache'. Works fine.
Firefox 3.5 under Tools has the option for Private Browsing. Click that to disable caching.
Here is how I have done it for flex/flash and silverlight and it works.
Code Behind ASPX or CSHTML
string slUrl = "/ClientBin/MySilverlight.xap";
string filePath = Server.MapPath(slUrl);
FileInfo info = new FileInfo(filePath);
// this will force browser to
// re download file if file was
// updated
slUrl += "?t=" + info.FileWriteTime.Ticks;
ASPX or CSHTML
<embed ....
src="<%= slUrl %>"
..
/>
Trick is you have to change url by adding something after ? and make a new arbitrary random query string or use file write time, and for browser, something?t=1 and something?t=2 are two urls and it will not pickup cache if t changes.
Instead of write time, you can also choose any standard config value or you can even simply hardcode your ASPX or HTML and append something after ? that will force browsers to download silverlight xap file again.
<embed ....
src="/ClientBin/MySilverlight.xap?something-different-each-time"
...
/>

Resources