aspose file tools*
The moose likes HTML, CSS and JavaScript and the fly likes js not refreshed? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "js not refreshed?" Watch "js not refreshed?" New topic
Author

js not refreshed?

Hengki Widjaja
Ranch Hand

Joined: Oct 31, 2011
Posts: 44
I have an external jsfile which only has 2 simple functions:


It all went well, until I edit the function go(). I simply omit that function, restart the apache, but the message "go" still appears. Is the js file cached and somehow not refreshed even after apache restarts? thanks
Rajkamal Pillai
Ranch Hand

Joined: Mar 02, 2005
Posts: 443
    
    1


You might want to clear your browser cache and also set the browser to reload the page from the server and not from its cache.
Hengki Widjaja
Ranch Hand

Joined: Oct 31, 2011
Posts: 44
Is it possible to do the settings programmatically? It's not always possible for the client to remember this. Or even better, is there anyway that the container compare the requested js and see if the js file has been updated. if it's updated, then resend the js to browser, if not, let the browser load from cache. thanks
Rajkamal Pillai
Ranch Hand

Joined: Mar 02, 2005
Posts: 443
    
    1


I doubt the possibility.

All of that is about how the client browser loads the page. One approach I can think of is to set the JSP headers:



Raj.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60049
    
  65

Except that, of course, Java code should never be put into a JSP written after 2001. And how would that help with the JS file in any case?

If headers are to be added to the response, it should be done in a filter.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Rajkamal Pillai
Ranch Hand

Joined: Mar 02, 2005
Posts: 443
    
    1


I was talking about setting the Response headers from Java code (Servlet/Action).

Raj.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60049
    
  65

Raj Kamal wrote:I was talking about setting the Response headers from Java code (Servlet/Action).

You said "JSP headers" and showed JSP syntax. Besides, doing this in a servlet or action also won't affect the JavaScript response.
Rajkamal Pillai
Ranch Hand

Joined: Mar 02, 2005
Posts: 443
    
    1


Bear,

Well thanks for bringing that to my notice. In a hurry to post a reply I guess it slipped through. Apologies....

Now from JSP or from Servlet/Action when I set 'no-cache' and 'Expires' it would mean that the client browser would recognize that the page needs to be loaded from the server and not from the cache, correct? And my understanding is that using both of these would enforce a server call for rendering the page. (A server call would mean that all resources associated with the page - including scripts - would be reloaded.)

I might learn something here so please be kind enough to correct in case I am wrong.

Raj.
Rajkamal Pillai
Ranch Hand

Joined: Mar 02, 2005
Posts: 443
    
    1

Removed duplicate post.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60049
    
  65

Whether the page is cached or not has nothing to do with whether the images and other resources in the page are cached or not.
Rajkamal Pillai
Ranch Hand

Joined: Mar 02, 2005
Posts: 443
    
    1

So a Request to the server does not mean that all resources associated with the page should also be reloaded? The resources could be loaded from the browser cache. Is that what you meant?

Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60049
    
  65

Yes.
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
If you do not want it cached, have your build script append a build number to the query string if the files. The query string means nothing and it will force the browser to fetch the new copy.

Eric
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: js not refreshed?
 
Similar Threads
javascript import
Javascript resize issue in IE
Begginer question, assigning a java string the value of a passed parameter
get the textbox values
Calling javascript function in js file from JSP