1

In our application we use Sencha GXT and GWT 2.7.

Unfortunately there's often the following error displayed in a pop-up:

Download of /path/deferredjs/SOMEGENERATEDID failed with status 404 ("Script Tag Failure - no status available")

It only seems to occur when a new version of the application has been deployed. Clearing the browser cache solves the problem.

I found out that this error occurs in the class ScriptTagLoadingStrategy.java in GWT.

Is there another way to solve this problem other than clearing the browser cache every time it occurs?

Harold L. Brown
  • 8,423
  • 11
  • 57
  • 109

1 Answers1

1

It seems that your HTTP's server configuration regarding caching is not properly configured to work with GWT.

According to the documentation:

  • *.nocache.* should not be cached
  • .cache. can be safely cached

There's an example configuration for Apache HTTP server in the documentation too.

The *.nocache.js file is a bootstrap script:

This file is responsible for choosing the correct version of your application to load for your client based on their browser and locale (...). The various versions of your application compliant to each browser / locale are the <md5>.cache.html application files.

In short: the bootstrap file changes every compile and is a "gateway" to your application. It selects which <md5>.cache.* application version to load. Its name has to be constant because you are referencing it from your host page. Since <md5>.cache.* files' names change with every source code change (because its name is its content's MD5 hash), they can be safely cached.

So what is happening is that an old bootstrap script is cached (and loaded instead of the new one) and it's trying to load an old version of your application (one of the *.cache.* files). However, those files have been probably removed by the compilation/redeploy, hence the 404.

Igor Klimer
  • 15,321
  • 3
  • 47
  • 57
  • But according to [this GWT documentation](http://www.gwtproject.org/doc/latest/FAQ_DebuggingAndCompiling.html#What) the caching of the .nocache. files is prevented: "To help prevent caching, the code in gwt.js actually appends an HTTP GET parameter on the end of file name containing a unique timestamp." So I'm not sure if this Apache configuration should be necessary. – Harold L. Brown Mar 05 '15 at 15:10
  • 1
    That seems to be a leftover from the old times - `gwt.js` has been used in GWT 1.3. [Starting from 1.4.10](http://www.gwtproject.org/release-notes.html#Release_Notes_1_4_10), the bootstrap procedure uses [just the `*.nocache.*` file](https://code.google.com/p/google-web-toolkit-doc-1-5/wiki/FAQ_GWTApplicationFiles). Do you have a `gwt.js` file in your project? Do you load it in your host page? You can see the requests made to the server in your browser's developer tools and verify yourself if the files are cached, are fetched again, etc. – Igor Klimer Mar 06 '15 at 08:58
  • Indeed there is no `gwt.js` in the `war` folder. So I guess I have to check the HTTP configuration of the server. – Harold L. Brown Mar 06 '15 at 09:48
  • Wouldn't it be possible to add a unique ID to the `*.nocache.js` file so that it never gets cached? [Like mentioned in this answer](http://stackoverflow.com/a/7413243/3067148). – Harold L. Brown Mar 06 '15 at 10:25
  • 1
    Yes, that's another way of making the browser fetch the file every time the page gets loaded. But I believe that this problem should be solved by setting proper cache related headers, not by some "versioning" tricks. Especially when you want to ensure that `*.nocache.js` never gets cached, while **also** ensuring that `*.cache.*` files will *always* get cached (they can easily weight over 1MB and you don't want the user to download that again and again). – Igor Klimer Mar 07 '15 at 11:18