Bs Contact Cache issues and solutions

vcard's picture

Those who start creating vrml/x3d online scenes and worlds and use "bs contact" as the viewer (like we do in babelx3d/abnet and other similar servers using contact) may have found themselves facing this kind of issue: "Viewing the world on my hard drive, Contact displays the world correctly first time every time, but after updating if I upload to my homepage and try to display it there, It often comes out with problems. The update just made apparently is not online, or I see random textures and objects, or some scripts do not behave as expected, etc." This seems like a malfunction, an error, a bug or a server problem but ... most probably is simply an annoying cache problem.

Caching to accelerate loading online scenes and worlds

This feature known as local hard disk cache was firstly introduced In 1999 on blaxxun contact version 4.2 (an antecessor of bs contact). "In addition to HTML browser caching, BS Contact supports a mechanism to cache VRML files and referenced media such as textures, sounds and movies on the local hard disk".

"Caching means that BS Contact stores downloaded content files on disk. The next time such a file is loaded - either because the user views the same scene again or because the file is part of multiple scenes - then this file can be loaded from disk, which is faster than retrieving it over the net again".  Upon installation bs contact sets the cache to "Verify once per session" but allows other manual settings to fine tune the cache process.

bs contact cache settings
Default cache setting on bs contact

According to bitmanagement this should work well in most cases because, on theory, with the default Setting 'Verify once per session", all files retrieved by BS Contact are written to the cache with the server timestamp. The next time the files are needed, the current VRML server file date is compared with the VRML cache file timestamp. If the dates are identical, all referenced media files are read directly from the cache without further HTTP requests. This should greatly improve loading performance if the world is revisited frequently.

What world creators should do to avoid cache trouble?

The cache default settings work well for end users and a simple cache cleaning using [Empty cache now] button, from time to time, solves common problems.

Creators have more issues with cache because in the developing process they update/upload the scenes many times increasing the possibility of errors and cache corruption. Adding to this the default 'Verify once per session" setting is not adequate for creators because it does not compare each time the cached version with the online version. In order to avoid problems creators should:

On bs contact
-check "every visit" in bs contact cache settings
-keep disk cache size low (look at the values in the picture above, for reference)
-Clean bs contact cache often

Your Internet browser cache (Internet explorer, firefox, chrome, ...) also counts, so
-Check "Every time I visit the web Page" (look for "Internet Options">>"browsing history">>"settings")
-Keep keep disk cache size low. Around 75 MB, or less is ok.
-Clean your browser cache often

With these settings and good practices the worlds will load a bit slower but you avoid a lot of troubles while creating them.

The "no_cache" directory solution

The measures proposed above are not the only ones. They are good but not full proof in avoiding you cache problems. For instance, you can easily forget to do the settings again if you (re)install another version of bs contact. Online world creators should consider using a "no_cache" online directory while developing their worlds. Quoting blaxxun/bitmanagement "Media placed in locations containing '/no-cache' in the URL are retrieved each time."

If you plan on doing lots of updates, you might want to store it in a directory called no_cache (for example: http://www.site.net/no_cache/world1.wrl). This prevents your world from getting cached in the user's bs contact file cache. When your world is finished, if you want to give your visitors the benefit of the cache, move or copy the concluded world to a normal directory on the server.

More ...

-Look for more cache info and settings on bs contact user guide

-Discuss cache issues, comment and/or propose solutions on forum thread: Bs Contact Cache - issues and solutions