為了改善您的使用體驗,本網站正在進行維護,部分功能暫時無法使用。若本站的文件無法解決您的問題,想要向社群發問的話,請到 Twitter 上的 @FirefoxSupport 或 Reddit 上的 /r/firefox 發問,我們的社群成員將很快會回覆您的疑問。

搜尋 Mozilla 技術支援網站

防止技術支援詐騙。我們絕對不會要求您撥打電話或發送簡訊,或是提供個人資訊。請用「回報濫用」功能回報可疑的行為。

了解更多

I cannot get the browser to reload a JavaScript file.

  • 6 回覆
  • 5 有這個問題
  • 1 次檢視
  • 最近回覆由 Spector

more options

Firefox 48.0 on Ubuntu (Virtual Box guest machine on Windows 7 host). I have searched long and hard all over the net and cannot find anything that works. The js is in shared windows folder, mounted within Ubuntu, as is the whole web app. Generally the app works fine, but if I have to tweak a Java Script, the browser will not use the new file. I have tried:

  • Developer web console is open and "Disable Cache" is checked.
  • ctrl-r
  • ctrl-shift-r
  • ctrl-F5
  • Holding own shift when pressing the browser reload button.
  • Going to Menu|Preferences|Advanced|Network and pressing [Clear Now]

I am using a framework so I cannot add a version/timestamp on the end of the script file name.

The only way I have found that works so far is to shutdown the machine and bring it up again. That takes a long time for a simple script tweak/test to show up. It is wasting a LOT of my time...

Please, is there a faster, easier way to get Firefox to use that new file?

Firefox 48.0 on Ubuntu (Virtual Box guest machine on Windows 7 host). I have searched long and hard all over the net and cannot find anything that works. The js is in shared windows folder, mounted within Ubuntu, as is the whole web app. Generally the app works fine, but if I have to tweak a Java Script, the browser will not use the new file. I have tried: *Developer web console is open and "Disable Cache" is checked. *ctrl-r *ctrl-shift-r *ctrl-F5 *Holding own shift when pressing the browser reload button. *Going to Menu|Preferences|Advanced|Network and pressing [Clear Now] I am using a framework so I cannot add a version/timestamp on the end of the script file name. The only way I have found that works so far is to shutdown the machine and bring it up again. That takes a long time for a simple script tweak/test to show up. It is wasting a LOT of my time... Please, is there a faster, easier way to get Firefox to use that new file?

由 Spector 於 修改

被選擇的解決方法

I finally got this figured out. By adding a line to my nginx server block it is now working . The line:

sendfile off;
It seems because the script file was on the host, not the guest and in a mounted shared directory there were issues with nginx 'knowing' the state of the file.

In case others need this, there were other symptoms that at the time I did not realize were connected. After editing the file:

  • The file has illegal characters appended
  • The file would have syntax errors
  • The file would be truncated
從原來的回覆中察看解決方案 👍 0

所有回覆 (6)

more options

No one can help? I am wasting hours rebooting to get the script to update as I debug the script.

more options

That's hard to understand. Is it possible there is some kind of external caching?

What if you load the .js in its own tab and Ctrl+Shift+r there -- any difference in behavior from when it is linked into a page?

more options

Loading the js in its own tab, I see the file contents listed. If I update the js in my editor on the host and then press Ctrl+Shift+r, the file listing does get updated.

more options

Bizarre. So even after clearing the cache, or disabling the cache in devtools, or bypassing the cache on reload, the main page gets the old external .js but loading the .js stand-alone and bypassing the cache gets the new .js. Is there any difference other than the HTTP_REFERER between those requests? I can't think of what it would be, or why that would matter.

more options

I just saw a reference to this add-on as helping with "stuck" cached files:

https://addons.mozilla.org/firefox/addon/clear-site-cache/

Haven't tried it myself.

more options

選擇的解決方法

I finally got this figured out. By adding a line to my nginx server block it is now working . The line:

sendfile off;
It seems because the script file was on the host, not the guest and in a mounted shared directory there were issues with nginx 'knowing' the state of the file.

In case others need this, there were other symptoms that at the time I did not realize were connected. After editing the file:

  • The file has illegal characters appended
  • The file would have syntax errors
  • The file would be truncated