3

I'm just starting to play with Durandal, using the starter kit. I've added a very simple new view/viewmodel combination (essentially a copy/paste of an existing one from the sample) and mapNav()'d the route.

The problem is happening when I try to refresh my browser...the new view simply does not appear. It's not in the nav bar, nor can I navigate directly to the view by typing in the address bar. I know the code is (or should be?!) correct because if I go to the page in a different browser, everything appears as it should.

Is there some browser caching that Durandal is doing somehow? Sometimes F5 or Ctrl+F5 works to refresh, sometimes it doesn't. I also can't deep-link to a specific 'page'. Ie:

http://localhost:52625/#/newpage just gives me a blank

What am I missing?

AR.
  • 39,615
  • 9
  • 44
  • 52

2 Answers2

5

The option that I use in Chrome is to open developer tools and right-click on the refresh button. There is an option for 'Empty Cache and Hard Reload' which always fixes this issue for me. I don't know the equivalent in IE but try this and see if it fixes your issue.

enter image description here

wal
  • 17,409
  • 8
  • 74
  • 109
PW Kad
  • 14,953
  • 7
  • 49
  • 82
  • Amazing! I'm using Chrome Developer Tools for years and I've just seen new refresh functionality! – Saeid Aug 18 '15 at 11:44
3

Most browsers will cache modules returned via RequireJS, which is how Durandal obtains its modules and view models.

CTRL+F5 doesn't help because that just refreshes the initial page - all the modules are still requested using javascript (RequireJS), so they are usually pulled from cache first.

I've found it's best to disable caching in your browser's developer tools. Doing so will ensure that all network requests are loaded directly from the source and not from cache.

See this question for additional information: Debugging when using require.js cache

Another solution is configure RequireJS to set its urlArgs property: https://stackoverflow.com/a/8479953/91189

This solution works ok, but makes it harder to debug, at least in Chrome, because breakpoints are lost every time the module is loaded, since it's technically a different file being requested each time.

Community
  • 1
  • 1
Joseph Gabriel
  • 8,339
  • 3
  • 39
  • 53