Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

no caching .js files

Status
Not open for further replies.

edelwater

Programmer
Jun 29, 2000
203
0
0
EU
Ive installed a new dhtml menu systeem on one of our sites it is based on some .js-s which are included in each and every page. The js-s used to be empty (as dumbfiles).

We now have the situation that users do have to -refresh- before they can see the menu.

i already implemented response.expires -1 and meta http-equiv=expires ... doesnt seem to work. i guess its because there are these .js includes in each file which are not refreshed in the cache ?

 
Hi Edelwater.

We are having a similar problem to the one you describe. Our system consists of HTML, Perl, Javascript internal to the HTML, and several external Javascript .js files. We are having alot of problems when we need to change the external .js files, as the changes don't always appear while we are attempting to test them. It is extremely irritating. We do 'refresh', 'control/refresh', clear out the temporary Internet files in the browser, etc..., all to no avail. Then, maybe 30 minutes, or an hour, or a day later, or on a different computer, the changes are there.

Our system is in beta test, so of course, as the programmers, we are having TONS of changes to make. This caching of the .js files and not being able to get them to refresh is driving us all nuts.

We are using IE 5.5. Our webserver is NT 4.0.

Interesting that there have been no responses to this problem. I'd have thought it would be a common one. Hopefully someone who has had this problem and has resolved it will see this posting and reply.

Keeping my fingers crossed! (-:

Kathy

 
thread216-98003

Is something one user posted the other day, and here's an ASP solution that works very well for me:

<%
Response.Expires = 15
Response.ExpiresAbsolute = Now() - 2
Response.AddHeader &quot;pragma&quot;,&quot;no-cache&quot;
Response.AddHeader &quot;cache-control&quot;,&quot;private&quot;
Response.CacheControl = &quot;no-cache&quot;
%>

Anyone else?

:)
paul
penny.gif
penny.gif
 
Thank you Paul.

However, I'm not using ASP. Will this work with straightforward HTML and Javascript? If so, where would I code it - it doesn't look like Meta tags.

Kathy X-)
 
No, the little thing I posted is an ASP only solution (that's what I use, so it's the only one I know for sure works) -- but what the other member posted (the thread link) is a javascript solution, and they put a pretty good explanation of how to use it in the post.

:)
paul
penny.gif
penny.gif
 
Hi all,

Perhaps this Metatag is an answer. I've used it both in ASP and CF.

<HTTP-EQUIV=&quot;PRAGMA&quot; CONTENT=&quot;NO-CACHE&quot;>

Hope this helps? :p

Kristof
 
may be u shuld try the followin:
<script language=&quot;Javascript&quot; type=&quot;text/javascript&quot;>
<!--
s = Math.random();
document.write='<'+'script language=&quot;Javascript&quot; type=&quot;text/javascript&quot; '+'src=&quot;date.js?'+ s +'&quot;><'+'/script>';

//-->
</script>


didnt used it myself, but i think it might be the way...

regards, vic
 
Kristof,

I will try that option.

I would like to know, though, if there is an option that will know enough to pull the new .js files if they are actually new, otherwise get them from cache. I think that is what the browser I'm using is attempting to do now, but it isn't smart enough to check the included .js file dates or something. Guess I want to have my cake and eat it too...

Does this same type of problem occur with .gif and .jpg files if they change but the HTML itself doesn't? I haven't run across it, as those files on our site don't change very often.

Thanks for your help!

Kathy ::)
 
Hi Vituz.

I have a question about your solution to the problem. It seems to make pefect sense for the most part, but can you explain to me (sorry for my ignorance) what pulling a random number and appending it to the end of the file name will do for us? Or does that &quot;?&quot; have some special significance in this script?

document.write='<'+'script language=&quot;Javascript&quot; type=&quot;text/javascript&quot; '+'src=&quot;date.js?'+ s
+'&quot;><'+'/script>';

Thanks!

Kathy %-)
 
well, what i mean is a get method that dhtml forms use, & for

my opinion:(i might be wrong)
when brawser c some src, it try 2 get the hole src usin GET request from server, when it got it , it has:
• location
• location anchor
• location search
so, search.htm?s=1 & search.htm?s=2 are totally different files
so, i thought it culd happen also with script src

am i wrong?
excuse me for dirty english..
ps: it is just unchecked suggestion, if ya want - try it, it culd be workin...

regards, vic
 
Hi i had the same problem last week and was given a solution from DeZiner.

It worked for me!!

The code to use is

<HTTP-EQUIV=&quot;PRAGMA&quot; CONTENT=&quot;NO-CACHE&quot;>


Although IE has a bug sometimes, Microsoft advise you to put the code at the top and also the bottom of the page.

(Example)

<HTML>
<HEAD>

<HTTP-EQUIV=&quot;PRAGMA&quot; CONTENT=&quot;NO-CACHE&quot;>

</HEAD>

<BODY>

</BODY>

<HEAD>

<HTTP-EQUIV=&quot;PRAGMA&quot; CONTENT=&quot;NO-CACHE&quot;>

</HEAD>
</HTML>



to learn more read the microsoft article:


Good Luck.

Wullie X-)
 
Pepsi, have u checked it in ie4.0? as i wrote before, i've got a problem with overflow:hidden in ie4.0; have u?

thunx anyway...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top