/    Sign up×
Community /Pin to ProfileBookmark

[RESOLVED] External Javascript not Refreshing!

I’ve got a web page that uses an external javascript. Right after I first launched the page our customer found an error in the calculation. I immediately fixed the problem and the code works fine now. However, this one location where the problem was found is still getting the error. All other locations that I’ve checked work fine. I’m guessing that the script is being cached somewhere, but I don’t know where. I know it’s not the local machine, because the individual I’m working with tried another machine at the same location that had never been to the site and got the same error. Any insight into this problem would be very useful. Is there a way to always make a page refresh the external javascript that would be great! Thanks!

to post a comment
JavaScript

12 Comments(s)

Copy linkTweet thisAlerts:
@Declan1991Apr 15.2008 — It sounds like a server error, but I didn't quite get it. Is there a problem for all users that it is not refreshed, or just a couple. If the latter is true, check things like browser.
Copy linkTweet thisAlerts:
@nbcrockettauthorApr 16.2008 — The problem is only happening to people at a certain company. I've had them refresh the page and clear all of their browser cache, but they still have the problem.
Copy linkTweet thisAlerts:
@mrhooApr 16.2008 — Most company nets have a proxy server between their users and the internet, which can be caching the content from your server. That would be my guess.

This server could have caching rules that override yours.

If the html is being refreshed but not the js add a get tail to the js file to force a new fetch from your server-

<script src= "filepath.js?randomstring"

If the html isn't being refreshed, you need to speak to the network admin.
Copy linkTweet thisAlerts:
@nbcrockettauthorApr 16.2008 — Is this what your talking about?

[CODE]<script type="text/javascript" src="/Scripts/MyScript.js?strRandom=1"></script>[/CODE]
Copy linkTweet thisAlerts:
@jasonahouleApr 16.2008 — Yes, but it doesn't have to be that. Just append a random string to the end every time the page is served. Don't use "?strRandom=1" every time because that isn't random and will entirely defeat the purpose.
Copy linkTweet thisAlerts:
@nbcrockettauthorApr 16.2008 — I don't think I would need it to refresh everytime they go to the page just this first time since I made a change. If I do need to make it random what would the code be? Thanks for your help!
Copy linkTweet thisAlerts:
@jasonahouleApr 16.2008 — What server side language are you using?
Copy linkTweet thisAlerts:
@nbcrockettauthorApr 16.2008 — asp pages using vbscript
Copy linkTweet thisAlerts:
@jasonahouleApr 16.2008 — So something like this would work
<i>
</i>&lt;script src="file.js?&lt;%= Now() %&gt;" type="text/javascript"/&gt;
Copy linkTweet thisAlerts:
@nbcrockettauthorApr 16.2008 — Do you not need what I marked in red?

[CODE]<script type="text/javascript" src="/Scripts/MyScript.js?[COLOR="Red"]strRandom=[/COLOR]<% = Now() %>"></script>[/CODE]
Copy linkTweet thisAlerts:
@jasonahouleApr 16.2008 — no, you just need something that will change in the query string. The timestamp will always be different. It won't help or hurt you to have the "strRandom" there.
Copy linkTweet thisAlerts:
@nbcrockettauthorApr 17.2008 — Thanks to all for the help! The below code is what I used to make the server refresh. I didn't make the code random because I didn't see a need to have the server recache the script everytime someone went to the page. Changes to the page will be few if any. However, anyone reading this post later shouldn't discount the random method, it could be very useful in certain situations. Again thanks for all the help.

[CODE]<script type="text/javascript" src="/Scripts/MyScript.js?1"></script>[/CODE]
×

Success!

Help @nbcrockett spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 7.20,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ,
analytics: Fullres
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: Anonymous,
tipped: article
amount: 1000 SATS,

tipper: Anonymous,
tipped: article
amount: 1000 SATS,

tipper: @Nanditha,
tipped: article
amount: 1000 SATS,
)...