Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    How to force browser to use latest code

    When we deploy a new build of our SmartGWT application the user's browser doesn't always run the latest version of the code. The user has to clear their browser cache to get the updated app. Is there a way to force the browser to recognize the new version?

    #2
    Advice for handling this for any other website also applies to SmartGWT. You can place the resources at a distinct URL, for example, to ensure caching is defeated. Or, right before the new release, you can decrease the amount of time that the Expires headers allow resources to be cached.
    Last edited by Isomorphic; 10 Apr 2012, 14:58.

    Comment


      #3
      Thanks. I did a little more research and found out more about GWT's "perfect caching" strategy. But for that to work you still need to implement something on the server to prevent caching of the myApp.nocache.js file. This blog post describes how to create a filter in Tomcat (the app server we're using) to properly handle the *.nocache.js file produced by the GWT compiler.

      Comment


        #4
        Yes, that solves part of the problem, it's actually a bit of a fancy name for the ability to cache .js files as application logic, which has been around a long time. However when you consider cached media files and other related files, GWT's "perfect caching" is actually just handling a portion of the problem.

        Comment


          #5
          HTML5 Application Cache

          http://www.w3schools.com/html/html5_app_cache.asp

          Comment


            #6
            Originally posted by jay.l.fisher View Post
            When we deploy a new build of our SmartGWT application the user's browser doesn't always run the latest version of the code. The user has to clear their browser cache to get the updated app. Is there a way to force the browser to recognize the new version?
            Hi!

            I developed my own version checking logic.
            When I build my app, I put the version number I entered during build process combined with timestamp into my properties file, both on client and server. When server starts, it reads that token so it knows its actual version. After deployment of the new version, I deliberately invalid all session so all clients have to relogin. After login, a client app sends its version to the server and the server responds with specific token if they differ. Then a client app presents a dialog with message "Press Ctrl+F5" to refresh version. Not perfect, but works for me.

            Comment


              #7
              Originally posted by jay.l.fisher View Post
              When we deploy a new build of our SmartGWT application the user's browser doesn't always run the latest version of the code. The user has to clear their browser cache to get the updated app. Is there a way to force the browser to recognize the new version?
              Is there a more current solution to this problem? A filter to expire the "nocache" file doesn't seem to be doing the trick. Thanks!

              Comment


                #8
                Just change the path with each version, e.g. include the version number in the path.
                yourApplicationV0102

                Comment


                  #9
                  The thread is old, but the standard caching rules that browsers follow have not changed - everything here is still true.

                  Comment

                  Working...
                  X