26 Nov 2015

I Make Changes and Nothing Happens

Things are going great. You have figured out how to upload a file, how to translate it, and maybe even add an extension or two in the viewer. Then it happens. You make a few changes in your design model or code and when you view the new version on your website site, nothing has changed.

Your fix isn't fixed. Your change isn't changed. NOTHING HAS CHANGED! You want to scream, pull out your hair, pound on your computer, and shout blame.

Headacke

 

Hang on. Calm down. A great many errors are in fact mistakes born of haste. Even if you're operating under a tight deadline, try to remain calm, and collected, as you proceed. It will help. If you start to get unduly tense, or frustrated, simply get up and walk away for a few minutes. Sometimes all it takes is a fresh, rested pair of eyes to spot a missing semi-colon, or an extra quotation mark, or two to realize that the solution is much simpler than you originally thought. The problem might be with the viewer, it might be with your database, it might be with your server, or it might be something you did to screw things up, but the reality is that a lot of the time it is none of those things. The culprit is probably your Internet browser. Whatever the problem is, we're here to help.

Let's look at the possible problems and solutions for what to do when you make a change and nothing happens.

 

The Browser Cache

Did you know that a computer is supposed to make your life easier? Less complicated? It is supposed to save you time and energy and actually improve your life. No? Well, maybe not, but your Internet browser does its best to try to make your life a little easier.

When you first visit a web page, it often takes a while to load, right? But the next page you visit within that site doesn't take so long to load. This is because, in an effort to be helpful, the browser stores the information on your computer so it reloads it from your computer, not from the actual site. This is called the cache and it is meant to speed up your Internet browsing.

The problem comes when you make a small change to your site and the browser doesn't recognize it as a significant change, so it reloads the same page you just looked at. The solution is to clear or empty your browser's cache.

 

Clearing the Browser Cache

Normally, to see the changes on your page, you click the Refresh button on the browser toolbar or press the F5 key on your keyboard. In many cases, this simply reloads the page without clearing the browser's cache. There are some techniques to wipe clean the browser's cache so you will see the changes when your page reloads. On Chrome, I added a shortcut plugin to do the work, it is call 'The Clean Cache Shortcut', but there is equivalent solution for the other browsers such as the Ctrl-Shit-R for Firefox, and etc... Just try this before anything else.

 

Server-side Caching

Sometimes, your server might cache code/pages as well, or if you're running Node.js, you need to restart the server to see teh changes. It is always a good idea to disable server cache while developing. But make sure to test it with cache enabled before going on production.

 

Viewer caching

During the last Acceleartor in Praha (Czech Republic), I worked with Marius-Mihai Golea
from Stabiplan,  on a solution using the View & Data API, and Marius-Mihai had a cache issue when re-loading a different version of a model using the same URN.

It is true that if you use the same bucket/filename, the URNs will be identical, and to speed-up your viewing experience, the Autodesk viewer cache the information for 24h. So if you try viewing a changed URN, you'll immediately end-up seeing the same model again and again, unless you clear your cache.

After debugging the viewer code, Marius-Mihai came out with a very neat solution which does not require you to clean the cache manually. His solution was to modify the viewer header request like this:

Autodesk.Viewing.HTTP_REQUEST_HEADERS ={
"If-Modified-Since": "Sat, 29 Oct 1994 19:43:31 GMT"
} ;

Very efficient and simple,

This is only needed when you modify and re-translate your design file again and again in your workflow within the same session. The advantage of this technique is that you are not really cleaning the cache, you only force the viewer to reload the model definition from the server vs using the cache.

Cleaning the cache wasn't a solution in this case even if it would have helped. Marius-Mihai addressed the real issue vs hiding it.

 

Special thanks to Marius-Mihai for sharing his solution with us,

Thumbs-up

Related Article