changes and deleting of a php file hosted locally - javascript

A PHP web application hosted locally on XAMPP does not accept changes or deletion of its files.
Whenever I make changes to a code in the file and run it , the browser displays the changes, but after a refresh, the changes are reversed.
i tried to delete the file or other files, but they come back when i refresh the pages.
I made changes to some codes in the files, and after saving them, the changes appeared just once in the browser. After refreshing the page again, all changes are reversed back to the old state. i tried deleting those particular files but it returns like it never happened.
Can someone help with a solution please? Thank you.

Maybe it is a permissions problem in your local XAMPP.
Did you try these actions on a server? I remember that sometimes the act of deleting doesn't work in my local project but when I test it on the online server works correctly.
I hope that this info helps you.
Kind regards

Related

why doesn't my live server work in visual studio code?

My live server on visual studio keeps opening an old html file when i try to open my current one. Ive tried reinstalling the extension but its the same problem. Can anyone help please
i cannot have two project folders with an html file running through the live server. Only one html file can be streamed at one time other wise when trying to stream the second, it will stream the first (Like the issue i was having)
I was having the same problem but later on I find out that, I renamed my project folder while my server was still loading the same project but with the previous folder name so I changed the link to my new folder folder name and it worked for me.
I have live server will simply not work if there was an error in JavaScript file.
Even if you do an alert in the beginning of JavaScript file (for test purposes) but at the end of the file re-define a variable which was already defined before, this error will render liver server not working.
The html page will not respond as well.
Solution is to go to developer tools (F12), see the errors on console, fix them and save and the live server would be back in action! At least that was the case with me.
I had the same issue, sometimes it was an error on the console, or keep showing an old HTML, tried everything, deleting cookies, reinstalling everything and nothing worked,
Eventually, it worked with a hard refresh, what it really worked was to
Go to ---> vs code settings ----> extensions ---> live server config set as chrome private. So far no more errors!
The liveserver extension serves static pages like html files and it does not load javascript or typescript files. You need to setup a server yourself for example in react you use webpack to configure your local server and your app runs on a localhost:port. In a nutshell, you need to write a script for node to run your js files. And you won't need liveserver after that.

UwAmp server doesn't detect changes that've made in files

everyone!
I'm using UwAmp 3.1.0 for my php development but I had some troubles
with it.
It worked perfectly at the beginning and the server still works
perfectly now but whenever I made a change to a .js file or .php
file it doesn't reflect that change when I update the page in the
browser.
I went to the chrome dev tools and opened the source section to see if the file is exactly what I wanted but it shows the original version which I've amended a while ago. The links to all files are correct and they are in a subdirectory in www folder.
It's so frustrating as I can't see the changes in action. I checked
the syntax and everything is ok but it doesn't want to stop an
animation in jquery after I it was fully shown to the user.
Can you help me with this situation as I have no idea what's causing the problem here?
It should update the file instantly when I click refresh in the
browser but it doesn't and keeps loading the version of the files
that I started to work with.
Uwamp is AMP stack (Apache, MySql and PHP) and "out-of-the-box" it doesn't have anything with caching of files.
Apache is normally reading/getting files from Uwmap www folder "as is" so basically if your last change is saved into file in www folder (please check directly with tools like notepad) Apache will read it instantly.
This is related to your Browser Cache (Empty yours Browser/Chrome cache manually or install Chrome extension like [Clear Cache Extension]:https://chrome.google.com/webstore/detail/clear-cache/cppjkneekbjaeellbfkmgnhonkkjfpdn?hl=en) and try to clear cache but completely ("from begining of time" like Chrome said).
Also a workaround is to click that Empty Cache icon every save before refreshing the page beacuse it will clear it almost instantly (depending on how long time ago have you cleared your cache)
Also try to set OPCache in Php.ini (settings file) in Uwmap to Disabled (locate opcache settings in php.ini and put 0 to disable - you can access it from Uwamp GUI also).

On cloudflare I want to disable caching and see my website changes immediately that I've pushed live

On cloudflare I want to disable caching and see my website changes immediately that I've pushed live.
Things I've tried:
I've put development mode on.
Create a bypass on caching in page rules.
Purged an individual webpage.
Purged the website.
Set cache to clear every 2 hours.
None of the above worked.
Tech I'm using:
Angular2
SystemJS
Typescript which becomes javascript on build.
Firebase for hosting and database.
Cloudflare for SSL etc.
The only way people see my website changes, it if they hard refresh.
The main problem is I've got a javascript file called app.js and its has all my javascript in for my Angular app. And it doesnt seem like its trying to get the resource in the browser.
I've changed the app.js to app.js?1490959855777
And still doesnt fetch the file again.
I basically want to see my JS file without a user having to hard refresh.
Based on the discussion above, it looks like the caching is happening on the browser - since a hard refresh will get the new file contents.
I think what happened is CF told the browser to hold onto that file for a very log time. And the browser is listening to that request.
Because you can't ask your users to do a hard refresh, you'll need to rename the static files that are being cached so aggressively.

Weird sessionStorage behavior

OK, bear with me please, I'll try to explain the issue as detailed as possible.
I have 3 HTML (and appropriate .js) files.
I can add stuff to sessionStorage and I display the content of the sessionStorage when I'm located in either of the HTML files.
I'm running files locally on the latest version of firefox, which - as far as I know - supports sessionStorage in file://
So, everything works great, I can add stuff to sessionStorage in HTML1 and go to HTML2 and the data is displayed properly. I get the concept of sessionStorage and all is good.
But here's where it gets weird:
when I add stuff to sessionStorage in HTML1 and go to HTML2 via a-href, the content of sessionStorage is there. But if I click in the url bar and press enter, the content is lost. SessionStorage is "null". I go back to HTML1 and press ctrl+r (reload) and still, null. But when I click in url bar and press enter (while I'm in HTML1 page), sessionStorage content returns.
I've done several checks and it appears as if when I click in url bar and press enter, another sessionStorage instance is created.
This, however, does NOT happen if I upload the project on some server.
I'm wondering why - if firefox supports sessionStorage - this is happening when I run the application locally and what is really going on there?
Thanks for any kind of explanation.
Ok, it doesn't work locally since you are opening the files, you need to run it on a server.
The browser will tie the sessions together using the URL (and other internal stuff of course) which is why it works on the whatever server you upload to. This won't work with the file URLs as the browser seems them as different pages from different locations, and so the session isn't shared.
If you set up WAMP or something locally and run it through that, it will work. Which is exactly what xavierm02 suggested.
I'm quite sure that if you looks at files from the filesystem, browsers consider every single file like a domain. So no Ajax, no shared cookies, sessions etc. The thing I find weird is that you get to keep some sessions...
Imagine you have a user stupid enough to open an html file he downloaded, without those protections, that html file could see everything on the system. And as much as antiviruses and the OS warn you when you open a .exe (or equivalent), you won't get any kind of warning when opening a .html file.
You'll have to use a local server, something like WAMP probably. Or Apache if you can.

How can I edit a js file sent by the server before it gets to my browser?

During a normal browsing session I want to edit a specific javascript file before the browser receives since once it gets there it's impossible to edit. Is there are any tool for this? For what I need it I can't just save it and edit it on my disk.
I'm ready to learn how to program it myself but if anyone can point out more or less what I have to do I'd be very grateful. I'd have to intercept the packets until I have the whole file while blocking the browser from receiving it any part of it, then edit it manually and forward it to the same port.
I don't think I can do this by just using pcap, I've read a bit about scapy but I'm not sure if it can help me either.
Thanks in advance.
You'd need to implement some sort of proxy, or hook into an existing one, and intercept the file as it's being downloaded and replace it.
Not trivial for a beginner, but a good learning project.
If you are happy to, rather then editing a file, replace it with a local one, then I would* use Charles and its Map To Local function.
Actually, "did". This helped me debug a problem with a browser and a JS file I couldn't edit yesterday.
You can probably achieve whatever it is you are wanting to do by using the firefox firebug plugin, chrome's development tools or the firefox greasemonkey plugin.
Or you could enter the files domain into your hosts file and point that domain to your local machine (running a web server), edit & save that javascript file locally and serve it from your own web server.

Categories