3

Preview of javascript file[Dynamic] does not showing latest code. Why?


Problem

Visual studio Preview of task.js[Dynamic] is showing my old codes


Explanation of the issue

This is my current code in task.js file

enter image description here

But when i run my application and put break point in that screen, now the java-script preview showing my old code. The preview does not show my latest code.

see the below image, this is my old code. i have replaced $cookieStore.get('userInfo').UserId instead on 1 in taskby object from my old code.

enter image description here


NOTE

Please see the yellow markup in the above images for more proof.,


What am did - I was tried to solve this problem by below ways

  • Pressed Save button more and more times
  • Pressed save all button
  • So many times i have cleaned the solutions
  • also tried build and rebuild the solution.

But not working


My Questions :

  • Why is this happened?
  • And how can we solve this?

Update:

I got a answer for my second question

How can we solve this? Ans : - I have solve this issue by restart visual studio


But i don't know, why it's happened. Please tell me guy's, if you know.


sepp2k
  • 363,768
  • 54
  • 674
  • 675
Ramesh Rajendran
  • 37,412
  • 45
  • 153
  • 234
  • How about clearing your browser cache? We do that quite frequently when we change our javascript that it has become ritualistic. – JasonWilczak Apr 27 '15 at 16:12
  • Yep, i have cleared the browser cache. the issue was solved by restart the VS. but i don't know why the problem occurred? – Ramesh Rajendran Apr 27 '15 at 16:13
  • Did you try just clearing cache and not restarting VS? Does that work? There is a very similiar post [here](http://stackoverflow.com/questions/15646447/visual-studio-not-updating-html-javascript-to-server-browser) – JasonWilczak Apr 27 '15 at 16:14
  • I have tried to clear the browser cache and also hard refreshed the browser. But not working for me. once i restart VS, then solved. Now the problem was solved.**My Question is why this problem happened to me?** – Ramesh Rajendran Apr 27 '15 at 16:16
  • 1
    Javascript files are cached, by default, for performance. Normally, in a production env, these files aren't constantly changing, so this is perfectly acceptable. Your development machine would be acting this way as well, so you need to work around it. – JasonWilczak Apr 27 '15 at 16:18
  • Okay, well can you add this comment to your answer? because that's helps to some others. – Ramesh Rajendran Apr 27 '15 at 16:20

1 Answers1

2

Reason for the Issue

Javascript files are cached, by default, for performance. Normally, in a production env, these files aren't constantly changing, so this is perfectly acceptable. Your development machine would be acting this way as well, so you need to work around it. SO post on how JS files are cached


Solution:

In my experience, it is browser cache that causes this and, ritualistically, we just clear the cache before we run the site. So, in this order:

Change javascript

Save all

ctrl+shift+f5 in Visual Studio

When browser opens, hit f12, the ctrl+r (clear cache) and click yes

When cache clears, hit reload on page.

If above solutions are does not working, then please restart the visual studio

Community
  • 1
  • 1
JasonWilczak
  • 2,303
  • 2
  • 21
  • 37
  • Oh. man. did you fully read my question? i have fixed this by my own. **My Question is why this problem happened to me?** – Ramesh Rajendran Apr 27 '15 at 16:19
  • Yes, I answered your question and then, for future visitors, gave a way to work through the problem since restarting Visual studio every time you change a JS file isn't a viable solution :) . – JasonWilczak Apr 27 '15 at 16:20
  • 1
    Okay i have edited your answer for some other peoples, please don't remove my edits :) thanks ! – Ramesh Rajendran Apr 27 '15 at 16:23