0

I'm currently running a MAMP server that runs php. The php currently serves html that pulls from local javascript files to do certain behaviors like make an ajax call. I found that my changes to my javascript code isn't reflected when I go to localhost. Any ideas why this may be? Changes to my .html file would show but not changes to my .js file. It was working before. For example, I can delete everything I typed in the .js file and the web application still works as if I didn't delete everything. What's wrong with my environment?

I looked at this but this is irrelevant: JavaScript code in source doesn't reflect code that is actually executed

Community
  • 1
  • 1
Sticky
  • 3,671
  • 5
  • 34
  • 58
  • 6
    Try clearing the browsers cache – Ed Heal Feb 23 '16 at 18:38
  • 1
    press crtl+shift+r on pc or cmd+shift+r on mac – I wrestled a bear once. Feb 23 '16 at 18:40
  • IT WORKED! I don't understand though, I thought MAMP pulls from fresh code as I write it. It's updating normally now. What happened? – Sticky Feb 23 '16 at 18:43
  • No, that's not how MAMP works. You would need something like [CodeKit](https://incident57.com/codekit/) for that. MAMP is just a standard local server environment. – APAD1 Feb 23 '16 at 18:45
  • Thanks for the explanation! How come my browser gets the fresh javascript now though? This behavior is confusing – Sticky Feb 23 '16 at 18:46
  • In order to improve performance, your *browser* caches files it downloads. It does so according to the instructions in the response headers for the assets as well as (AFAIK) its own internal heuristics. So when you reloaded the page you were seeing an old copy of your js/css/html that your browser held on to. Using shift-cmd-r or shift-cmd-click on the reset button clears that cache so that the browser has to download the latest version of things. – Jared Smith Feb 23 '16 at 18:52
  • Try something like http://livereload.com/. Well worth the $10 from the app store. – Jared Smith Feb 23 '16 at 18:53
  • Thanks! Closed as duplicate :D – Sticky Feb 23 '16 at 19:25

0 Answers0