Closed Bug 234361 Opened 21 years ago Closed 14 years ago

It fails to reload JavaScript (.js) file that I modified, from a site I'm developing

Categories

(Firefox :: General, defect)

x86
Windows 2000
defect
Not set
normal

Tracking

()

RESOLVED INCOMPLETE

People

(Reporter: ferp, Unassigned)

References

()

Details

User-Agent:       
Build Identifier: Mozilla/5.0 (Windows; U; Win98; en-US; rv:1.6) Gecko/20040206 Firefox/0.8

I'm developing a site with ArcIMS (www.esri.com) that uses a lot of Jav Script
(.js). The problem is that when I change something in a file (.js) and then
reload the site the old version of Java Script (.js) remains loaded. Firefox
doesn't read the new file. Even if I shutdown and restart Firefox. In Firebird
there wasn't this problem. Firefox doesn't refresh the site like it should do.
Thanks!

Reproducible: Always
Steps to Reproduce:
1. I load a map website
2. Then change some variables in ons .js file
3. Then reload the site in many ways as I know (CRTL+F5, SHIFT+F5, CTRL+R,
SHIFT+CTRL+R, SHIFT+button Reload)


Actual Results:  
And the site remains as if I haven't change my .js file


Expected Results:  
It should change font size, drawing colors, number of frames, and other simple
things that are set in one .js file

Nothing like this! It just doesn't work like it should.
I have experience this problem with Mozilla too, I'm using Mozilla version 1.6.
 So, it look like it is not a Firefox issue after all.
I need to search the bugzilla for other bugs first.  But I'll add this comment
anyway, I found that this bug doesn't seem to apply if it is a local file on my
machine if I open the file from the Mozilla Menu, File --> Open File.  So, the
problem seem more had to do with receiving the file from the webserver instead
which it is in my case.
Well, I can't reproduce this problem exactly because it is an intermitted one
for me.  So, maybe one day...
*** Bug 242369 has been marked as a duplicate of this bug. ***
Mark, do you by any chance have a simple testcase that can reproduce this problem?

By the way, from observation, this bug seem to be noticable by anyone who write
codes for the website.  Because the Internet users only access the website after
starting up the browser or something.  They aren't the one who write/modify codes.
I have to clear the cache in order to reload an altered js file. The reload
button does not reload the .js file.

(In reply to comment #0)
> User-Agent:       
> Build Identifier: Mozilla/5.0 (Windows; U; Win98; en-US; rv:1.6)
Gecko/20040206 Firefox/0.8
> 
> I'm developing a site with ArcIMS (www.esri.com) that uses a lot of Jav Script
> (.js). The problem is that when I change something in a file (.js) and then
> reload the site the old version of Java Script (.js) remains loaded. Firefox
> doesn't read the new file. Even if I shutdown and restart Firefox. In Firebird
> there wasn't this problem. Firefox doesn't refresh the site like it should do.
> Thanks!
> 
> Reproducible: Always
> Steps to Reproduce:
> 1. I load a map website
> 2. Then change some variables in ons .js file
> 3. Then reload the site in many ways as I know (CRTL+F5, SHIFT+F5, CTRL+R,
> SHIFT+CTRL+R, SHIFT+button Reload)
> 
> 
> Actual Results:  
> And the site remains as if I haven't change my .js file
> 
> 
> Expected Results:  
> It should change font size, drawing colors, number of frames, and other simple
> things that are set in one .js file
> 
> Nothing like this! It just doesn't work like it should.
It would be nice to have this bug solve. It's annoying to close and re-open
firefox every time I am editing the js file.
thx dev.
One work around I've found is to load the JavaScript file's URL directly in a
window and shift+reload. If that doesn't work, there's a good chance that this
is a problem with your webserver caching the file.
I found less annoying way to take care of this problem. Not an elegant one I am
affraid. I reduced the cache size in firefox from default 5000 KB into 50 KB. It
smaller my js 54KB. So every time I am reloading the the page, all the component
get reloaded again.
>One work around I've found is to load the JavaScript file's URL directly in a
>window and shift+reload. If that doesn't work, there's a good chance that this
>is a problem with your webserver caching the file.

web server??

>I found less annoying way to take care of this problem. Not an elegant one 
>I am affraid. I reduced the cache size in firefox from default 5000 KB 
>into 50 KB. It smaller my js 54KB. So every time I am reloading the the 
>page, all the component get reloaded again.

I wonder if the caching itself and/or the cache size affect other files as part
of the html script, like *.css file(s), etc. (beside the *.js file(s)).  Because
I have noticed that a few times the *.css doesn't get refreshed as well.  Could
they all be related?

Mozilla seem to be affected as well, so is it a core bug or just a firefox only
bug?  Um, more investigations would be needed.  I just can't confirm this
because I'm using Seamonkey alot.  I haven't yet to come up with a testcase as
well.  I'll try if I have time.  As a webmaster, this is driving me nut sometime.

I'll try to do bugzilla search to collect more bugs and file a new bug, marking
it as a Product --> Core if sufficient bugs exists and mark all as dependant of
that future bug.  
"Whether changed file is got or cached data is used" depends on both client's
cache settings and server's cache settings.
To all problem reporters:
(Q1) What is your cache option settings?
(Q2) What is server's responce to HTTP GET for your JS file?
(Q3) Does problem occur even when "Shit+Reload" really?
(Q4) If problem occured even when "Shit+Reload" really in the past,
     does the problem still occur on newest release build of Firefox?
     How about newest build of firefox/nightly/latest-trunk?
     (Test with newly created profile or "Safe Node" is preferable.)
(Q5) Does problem occur on "<script src>"specified in HTML source?
     Or problem on JavaScript generated "<script src>" only?
     HTML in IFRAME or nested IFRAME only? Or main page too?

Go http://livehttpheaders.mozdev.org/index.html and install LiveHTTPHeaders,
then and obtain HTTP header log for both "Shift+Reload" and "Reload".
Go "about:cache" and check cache entries. 

(Example when "When the page is out of date" and server returns max-age)
 T1) xxx.js is created
 T2) Shift+Reload
     "Cache-Control: no-cache" is sent by Mozilla/Firefox
      and xxx.js is returned from server, then it is saved in cache.
     - Server returns "Last-Modified: T1"
     - Server returns "Cache-Control: max-age=NNN (Depends on server) 
 T3) xxx.js is changed at server
 T4) Reload by client 
     (When "When the page is out of date" is set)
     If (T4-T2)<NNN, HTTP GET is not issued to server and cached data is used.
     If (T4-T2)>NNN, HTTP GET is issued with "If-Modified-Since: T1",
        then server responds "304 Not Modified" when not modified,
                 or returns new data when modified(changed data at T3).

(In reply to comment #10)
When CSS file, different analysis is probably required since "@import" is
involved in CSS, and, as far as I remember, loading problem relates to multiple
or nested "@import" is already reported(I don't know whether fixed or not).
Zook Valem, search bugs relates to "@import".  
I have run across this issue on firefox 1.0.6 in linux as well.  I have found a
reliable method to force the browser to reload the JS files off of the server
WITHOUT quiting the browser, simply by pressing the "F5" key.  It works everytime.
Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.8b5) Gecko/20050927
Firefox/1.4 ID:2005092706

WFM
I have also had trouble with this behavior of Mozilla browsers, but I have had difficulty producing a minimal test case.   When I try, the problem goes away, so I wonder if it is file-size sensitive.

Here is, I think, a clearer statement of the behavior, and what I can do to reproduce it in my web apps.

1) Consider a web page (page.html) that links to both an external stylesheet (via <style type='text/css'>@import 'style.css'</style>) and to an external javascript (via <script src="script.js"></script.>

2) Edit something in 'style.css', visit 'page.html' in Firefox, and refresh.  The changed styles affect the page.

3) Edit something in 'script.js', visit 'page.html', and refresh.   The changes in script.js do not affect the page! 

4) shift-refresh 'page.html', and notice that the changes in script.js are still not reflected.

5) Visit script.js directly, by typing in the URL.  You will see the chached version without your changes to the code.

6) Shift-reload script.js, you will see the new version.

7) Return to 'page.html', and you will see the effects of your changes on script.js.


The complaint is that from a user perspective, force-reloading a page which contains linked files should trigger a refresh of those linked files.  However I have frequently observed that doing so in Firefox will reload css, image, and other linked files, but it will not do so for linked javascript files: .js files appear to be cached much more robustly.   The workarounds are to empty cache manually, visit the script directly and refresh it, or quit and restart firefox.   All of these workarounds are tedious, and therefore problems in a rapid development cycle.

It's difficult to produce a test case.   When I generate three small files page.html, style.css and script.js, I cannot reproduce the problem with those files, though I see the problem 100% of the time with files in large web applications I work on, on a number of different servers and on apache running locally on my development workstation.   Perhaps there is a size sensitivity in the caching algorithm?

(In reply to comment #14)
> 3) Edit something in 'script.js', visit 'page.html', and refresh.   The changes
> in script.js do not affect the page! 
> 
> 4) shift-refresh 'page.html', and notice that the changes in script.js are
> still not reflected.

> 6) Shift-reload script.js, you will see the new version.

(Q1) What is your Firefox build ID?
     Problem occurs even when -safe-mode?
(Q2) What is difference between your "shift+refresh" and your "Shift-reload"
     and your "force-reloading a page"?
(Q3) What is your cache option setting?
     Enter about:config, and see browser.cache.check_doc_frequency.
     (Default of firefox is 3. "When the page is out of date")
(Q4) What Expiration: is set in cache entry for the "script.js" file
     before step 3)
     Enter about:cache in URLbar, then see both Memory-Cache & Disk-Cache entry.
(Q5) See HTTP flow(see HTTP headers) both when 3) and 4).
     What HTTP headers are sent to/received from server?
(Q6) See HTTP flow(see HTTP headers) when Shift+Relod for the 'page.html'
     What HTTP headers are sent to/received from server?
(Q7) What Expiration: is set in cache entry for the "script.js" file
     after Shift+Reload of the 'page.html'?
(Q8) Is script generated <script src=...> involved?
(Q9) Do you modify SRC attribute value of <script> by JavaScript?

> 1) Consider a web page (page.html) that links to both an external stylesheet
> (via <style type='text/css'>@import 'style.css'</style>)
As I said in comment #11, @import may involve other issues.
Search bugzilla for "@import" please, if CSS related issue is involved.
(In reply to comment #15)
> (Q1) What is your Firefox build ID?

Mine is:
Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en-US; rv:1.8.0.3) Gecko/20060426 Firefox/1.5.0.3

But, I have observed this behavior in all firefox version I've tried on both Mac and Win anytime in the last year.

>      Problem occurs even when -safe-mode?

Unknown, don't know how to test this.

> (Q2) What is difference between your "shift+refresh" and your "Shift-reload"
>      and your "force-reloading a page"?

They are synonymous.   All mean holding shift key while clicking the two-blue-arrow 'reload current page' icon in the toolbar.  

> (Q3) What is your cache option setting?

default integer 3

> (Q4)(Q5)(Q6)(Q7)
I will try to get you answers to Q4 through Q7 at a later time when I am more free to make alterations to the server.   (At the moment it is being used by the client, so I can't go making changes willy-nilly).

> (Q8) Is script generated <script src=...> involved?
The page is output by PHP, but the src="" value of the <script> tag is nonvariable.

> (Q9) Do you modify SRC attribute value of <script> by JavaScript?

No

> > 1) Consider a web page (page.html) that links to both an external stylesheet
> > (via <style type='text/css'>@import 'style.css'</style>)
> As I said in comment #11, @import may involve other issues.
> Search bugzilla for "@import" please, if CSS related issue is involved.

@import generates the expected behavior.  In this case, it was just an example to illustrate the difference between linked js files and linked/included other files (like css).  Other files always refresh correctly when shift-reloading the page that includes them.  js files do not always do so in my experience.
Assignee: bross2 → nobody
QA Contact: general
Can you please try this with a new profile?

http://kb.mozillazine.org/Profile_Manager
Summary: It fails to reload Java Script (.js) file that I modified, from a site I'm developing → It fails to reload JavaScript (.js) file that I modified, from a site I'm developing
This bug was reported on Firefox 2.x or older, which is no longer supported and will not be receiving any more updates. I strongly suggest that you update to Firefox 3.6.3 or later, update your plugins (flash, adobe, etc.), and retest in a new profile. If you still see the issue with the updated Firefox, please post here. Otherwise, please close as RESOLVED > WORKSFORME
http://www.mozilla.com
http://support.mozilla.com/kb/Managing+profiles
http://support.mozilla.com/kb/Safe+mode
The investigation in this bug seems to have stalled. Closing as incomplete.
Status: UNCONFIRMED → RESOLVED
Closed: 14 years ago
Resolution: --- → INCOMPLETE
You need to log in before you can comment on or make changes to this bug.