2

I am using JBoss Application Server 4.2.

I have noticed that when I update an .xhtml file, my local server will immediately reflect the change. However, if I update a .js file, it will not update until I restart the server. This is a huge hassle when I am working with .js files; any time I want to test a change, I need to restart the server.

Is there a way I can force JBoss to stop caching the file? Please note, solutions like this one don't work; the framework automatically includes the .js file, and I cannot change the <script src="..."> text manually.

Community
  • 1
  • 1
patstuart
  • 1,931
  • 1
  • 19
  • 29

1 Answers1

1

This isn't a very elegant "solution," but I have three workarounds I've been using which mitigate the problem. I'll post them below for anyone else who has the same problem as I did:

  1. Edit the .xhtml file on the server to add a dummy GET variable to the filename in the <script src="..."> tag. See here. In my case, because I'm using an external framework, this meant editing a XML file, which the server apparently doesn't cache.

    • Advantages: this will reload properly every time.
    • Disadvantages: I have to make sure I don't deploy the code to production with the dummy GET variable. Also, I lose any breakpoints in my debugger, which doesn't recognize that it's the same JS file.

  2. Edit the file on the server, then make the exact same changes dynamically in Chrome debugger. See here.

    • Advantages: no need to worry about breakpoints or deploying bad code. No need even reload the page.
    • Disadvantages: the changes disappear as soon as I hit the reload button. Also, it's easy to make a mistake when synching the code.

  3. Put the JavaScript code in the .xhtml file under its own <script> tag, then migrate it over to the .js file when ready to commit the changes.

    • Advantages: page reloads properly each time.
    • Disadvantages: migrating the code to the .js is a hassle, and it's easy to accidentally introduce bugs.

Neither of these solutions is perfect, but they work as decent patches. Of course, if anyone has a real solution to actually make the server stop caching the file, I'd still love to hear it.

Community
  • 1
  • 1
patstuart
  • 1,931
  • 1
  • 19
  • 29