Cache issues for newbie..

Hi all… So I’m trying out Vaadin under OSX and it’s working OK for the most part but when I make incremental changes to my test app I almost never see the changes unless I clear the browser cache or turn on Private browsing in Safari. I’m assuming this is because the expiration of the cache is high – I’ve tried shutting down Tomcat and restarting but no luck with seeing my new changes… Any ideas on how this is supposed to work? Thanks!

Hi,

Adding ?restartApplication parameter to application URL will help (application must be redeployed for the changes to be reflected though). If you used
JRebel
or its free analogues - the only thing u’d have to do - is to refresh the browser.

cheers,
sasha.

Thanks! I’ll check out JRebel – for now I can live with the extra arg on the URL though but will need something like JRebel at some point…

(a) Besides adding this to your URL:

?restartApplication

you can instead add:

?debug

Then a JavaScript window appears. Click the “R” button for Restart. It appends “restartApplication” to the URL.

Either way you choose to append to the URL, you may want to delete the appended text after using it. Otherwise you may see your app continually restarted, which is not real-world behavior.

This business is annoying, but it’s the price we pay for working in the web app world (perverting a document-browser into an interactive app).

(b) Yes, JRebel is virtually required for serious Vaadin work, IMHO. You don’t need JRebel when first dabbling with Vaadin, but expect to be quitting and restarting your web server, browser, and Eclipse.

Once installed and working, when you simply save edits to a .java file, wait a moment, and you’ll see in the command-line panel of Eclipse a couple of lines explaining that your class was re-loaded. Eclipse+JRebel automatically re-compiles and re-deploys your class “hot”, without restarting your web server (Tomcat 7 in my case).

Some people using Vaadin seem to be allergic to using JRebel because it is not open-source. C’est la vie. JRebel does work as advertised, so I recommend it. Also, JRebel does not “muck up” your app or classes, so you can easily deploy to production
sans
JRebel.

Installing JRebel requires some voodoo, but worked for me by carefully following directions. Remember the last step applies to each new project:

  1. Select the project in Eclipse’s Project Explorer.
  2. Context-click to choose JRebel > Generate rebel.xml

JRebel does not eliminate all the hassles. That’s just life with web apps.

  • Sometimes, depending on your changes, you’ll need to restart your application as described above.
  • Despite using JRebel, when you make certain drastic changes, you’ll get a dialog offering to restart the web server.
  • Some web servers, such as Tomcat, save the Session object to disk between restarts. That Session object contains the current objects in the user’s Vaadin app execution. When restarting, the Vaadin app will be restored as if it were never quit. So even quitting and restarting your tools does not mean you are truly getting a fresh start.

–Basil Bourque

I strongly recommend disabling session saving in Tomcat in debug environments for this reason.

In Eclipse: Project Explorer → Servers → My Tomcat → context.xml and uncomment the “Manager” line as the comments in the file say (I hope I remembered all this correctly).

This may be a dumb question (or not relevant to Safari), but have you tried holding down ‘Shift’ when clicking reload? This is what I do in FireFox, Chrome, etc., and now it’s second nature to me.

Ah, reading
this article
makes it sound like this won’t work with Safari, but I guess you could still try it. If it doesn’t work, you may want another browser just for development work. A few minutes installing it now saves time in the long run compared to restarting the app through the URL or clearing your cache.

Cheers,
Bobby