3

I'm using XAMPP and opening my html file using localhost/filename.html. So both my html document and .js file are in the same directory, in C:/xampp/htdocs. When I open the html file using localhost/filename.html in the browser window, it does not include the changes to the code. It's using the same version of the .js file before I saved the changes. But when I open the html document locally (offline, not running on localhost), the changes to the .js are there.

For example, if I put document.write('foo') in the .js and then hit save, then opening with localhost/filename.html does not print "foo". But if I just open the filename.html through file explorer (on the same browser--chrome), it prints "foo"!

What could be causing this?

OS: Windows

Browser: Chrome

5
  • 1
    Could be a caching issue? Have you tried clearing your browser cache? Commented Apr 25, 2019 at 18:49
  • 1
    @Connum That worked! Thanks ! It was giving me a headache Commented Apr 25, 2019 at 18:52
  • 1
    Voting to close as non-reproducable, you might want to consider deleting the question yourself. Commented Apr 25, 2019 at 18:52
  • 1
    @Connum Sorry will do. Do you mind explaining what caused this issue? What it has to do with cache? Commented Apr 25, 2019 at 18:55
  • Hard to tell, could be a browser setting, long expire times set via htaccess or apache config... Commented Apr 25, 2019 at 19:20

1 Answer 1

5

Actually seams that clearing the browser cache solved the problem. i would like to link to a related page:https://superuser.com/questions/36106/force-refreshing-only-javascript-files-in-firefox-and-chrome

I had a similar issue. Here are some things you can try to fix it:
1-Clearing browser cache.(this one fixed mine)
2-Stopping and starting again Apache.
3-(if you use XAMPP control panel)Closing the the control panel and left-click on the icon n the taskbar(near to wifi-sound control or in the compressed up arrow) and clicking on quit
4-Stopping XAMPP; renaming htdocs to something else; editing the "C:/xammp/properties.ini" "apache_htdocs_directory" property to the new path you gave the htdocs.(This can break something so i suggest to repeat this step again after restarting XAMPP and changing back everything to default "htdocs"). 4-Shutting down the OS via cmd.exe with shutdown -s(I personally prefear to use cmd to shutdown because on some PC there's "fast boot" option enable, which means that it hibernates it to boot faster) and then restart the OS.
If I find anything else I'll add it to the list.
(I was still writing my answer while Connum was writing)

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.