Cache javascript source


Go Back   Computer Help Articles > Internet Explorer 6
User Name
Password
FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 01-05-2006, 04:23 PM
Andrew Clark
 
Posts: n/a
Default Cache javascript source

Hello,

I have a webpage to search a database. When the results are returned
from the query, they are written to a temporary file so I can include
them as a javascript source file. On any subsequent query, the correct
recordset is written to the file, but the results on the page are not
updated due to (I suspect) caching in internet explorer. Here is an
example:

search.html
--

<IFRAME SRC="blank.html" NAME="dataiframe"></IFRAME>
[...]
<FORM ACTION="getdata.php" METHOD="post" TARGET="dataiframe">
<INPUT TYPE="submit"
</FORM>

getdata.php
--

// perform a query and write to a file here
$filename = "tmp/some distinct file name";
echo "<SCRIPT TYPE=\"text/javascript\" SRC=\"tmp/$filename.js\">";
echo "</SCRIPT>";

Each time the database is queried, the IFRAME is reloaded. The .js file
is created correctly (looking at the .js file, the values reflect the
new recordset), but the new data never shows up. The first data set is
the only one to ever show up. I think the contents of the javascript
file are cached and IE never bothers to reload it. How should I deal
with this problem?

Thanks,
Andrew
Reply With Quote
  #2  
Old 01-05-2006, 04:23 PM
Rob Parsons
 
Posts: n/a
Default Re: Cache javascript source

Hi Andrew,

I will take a wild guess at this one. I think you need to pass another
parameter with your form post (a page no. perhaps)..
What are you trying to do. Pagenate your results?
You can test if caching is a problem by deleteing your files between posts.
If you are still having problems then I would suggest you search the php
newsgroups. Usually someone has written some solid code that do what you
want to do before.
"Andrew Clark" <lark047@hotmail.com> wrote in message
news:Xns971A81FD075720x120@66.150.105.47...
> Hello,
>
> I have a webpage to search a database. When the results are returned
> from the query, they are written to a temporary file so I can include
> them as a javascript source file. On any subsequent query, the correct
> recordset is written to the file, but the results on the page are not
> updated due to (I suspect) caching in internet explorer. Here is an
> example:
>
> search.html
> --
>
> <IFRAME SRC="blank.html" NAME="dataiframe"></IFRAME>
> [...]
> <FORM ACTION="getdata.php" METHOD="post" TARGET="dataiframe">
> <INPUT TYPE="submit"
> </FORM>
>
> getdata.php
> --
>
> // perform a query and write to a file here
> $filename = "tmp/some distinct file name";
> echo "<SCRIPT TYPE=\"text/javascript\" SRC=\"tmp/$filename.js\">";
> echo "</SCRIPT>";
>
> Each time the database is queried, the IFRAME is reloaded. The .js file
> is created correctly (looking at the .js file, the values reflect the
> new recordset), but the new data never shows up. The first data set is
> the only one to ever show up. I think the contents of the javascript
> file are cached and IE never bothers to reload it. How should I deal
> with this problem?
>
> Thanks,
> Andrew



Reply With Quote
  #3  
Old 01-05-2006, 04:23 PM
Andrew Clark
 
Posts: n/a
Default Re: Cache javascript source

"Rob Parsons" <iecustomizer@hotmail.com> wrote in
news:eHza2xr8FHA.1028@TK2MSFTNGP11.phx.gbl:

> Hi Andrew,
>
> I will take a wild guess at this one. I think you need to pass another
> parameter with your form post (a page no. perhaps)..
> What are you trying to do. Pagenate your results?
> You can test if caching is a problem by deleteing your files between
> posts. If you are still having problems then I would suggest you
> search the php newsgroups. Usually someone has written some solid code
> that do what you want to do before.
>
>
>


Thanks for your reply.

Here's what I'm trying to do: when the form is submitted, the database is
queried and a result set is returned based on criteria the user selects.
The result set is written to a .js file as javascript source so it may be
displayed using DHTML.

Each time the form is submitted, the .js file is created correctly, but for
the first recordset only do the correct results show up. The only reason I
can think of to explain this behavior is that IE is caching the .js file
and never reloading it.

This behavior does not occur in Firefox. That is why I think it is an IE
specific problem. Now I have a workaround in place to always generate a new
file and delete the old, but that seems messy to me. I would like to know
how to force IE to always read the .js file or not cache it.

Thanks,
Andrew
Reply With Quote
  #4  
Old 01-05-2006, 04:23 PM
Rob Parsons
 
Posts: n/a
Default Re: Cache javascript source

Hi Andrew,

Sorry for the delay. I am not sure if this will do the trick. I sorta don't
understand exactly how you are using js to write the results out
(document.write?)

But you may try the nocache header

<META HTTP-EQUIV="Pragma" CONTENT="no-cache">

The only other thing I can think of is to use a unique document.title for
each result set.


"Andrew Clark" <lark047@hotmail.com> wrote in message
news:Xns971B8118EA7160x120@66.150.105.47...
> "Rob Parsons" <iecustomizer@hotmail.com> wrote in
> news:eHza2xr8FHA.1028@TK2MSFTNGP11.phx.gbl:
>
> > Hi Andrew,
> >
> > I will take a wild guess at this one. I think you need to pass another
> > parameter with your form post (a page no. perhaps)..
> > What are you trying to do. Pagenate your results?
> > You can test if caching is a problem by deleteing your files between
> > posts. If you are still having problems then I would suggest you
> > search the php newsgroups. Usually someone has written some solid code
> > that do what you want to do before.
> >
> >
> >

>
> Thanks for your reply.
>
> Here's what I'm trying to do: when the form is submitted, the database is
> queried and a result set is returned based on criteria the user selects.
> The result set is written to a .js file as javascript source so it may be
> displayed using DHTML.
>
> Each time the form is submitted, the .js file is created correctly, but

for
> the first recordset only do the correct results show up. The only reason I
> can think of to explain this behavior is that IE is caching the .js file
> and never reloading it.
>
> This behavior does not occur in Firefox. That is why I think it is an IE
> specific problem. Now I have a workaround in place to always generate a

new
> file and delete the old, but that seems messy to me. I would like to know
> how to force IE to always read the .js file or not cache it.
>
> Thanks,
> Andrew



Reply With Quote
  #5  
Old 01-05-2006, 04:23 PM
Andrew Clark
 
Posts: n/a
Default Re: Cache javascript source

"Rob Parsons" <iecustomizer@hotmail.com> wrote in
news:O1076r58FHA.1140@tk2msftngp13.phx.gbl:

> Hi Andrew,
>
> Sorry for the delay. I am not sure if this will do the trick. I sorta
> don't understand exactly how you are using js to write the results out
> (document.write?)
>
> But you may try the nocache header
>
> <META HTTP-EQUIV="Pragma" CONTENT="no-cache">
>
> The only other thing I can think of is to use a unique document.title
> for each result set.
>
>
>
>
>


Thanks for your reply.

I am using PHP to write the result sets to a file, then including and
using the file with javascript. I tried

<META HTTP-EQUIV="expires" CONTENT="-1">

but that seems to have no effect on this problem. I saw the one you
mentioned as well and I will try it and get back.

Andrew
Reply With Quote
  #6  
Old 01-05-2006, 04:23 PM
Rob Parsons
 
Posts: n/a
Default Re: Cache javascript source

k saw your reply. Come back if it works. If it doesn't you may have to do
some research and maybe look for a different solution. There is bound to be
code out there that with a little effort can be modified to your needs.
"Andrew Clark" <lark047@hotmail.com> wrote in message
news:Xns971BEC3EB157C0x120@66.150.105.47...
> "Rob Parsons" <iecustomizer@hotmail.com> wrote in
> news:O1076r58FHA.1140@tk2msftngp13.phx.gbl:
>
> > Hi Andrew,
> >
> > Sorry for the delay. I am not sure if this will do the trick. I sorta
> > don't understand exactly how you are using js to write the results out
> > (document.write?)
> >
> > But you may try the nocache header
> >
> > <META HTTP-EQUIV="Pragma" CONTENT="no-cache">
> >
> > The only other thing I can think of is to use a unique document.title
> > for each result set.
> >
> >
> >
> >
> >

>
> Thanks for your reply.
>
> I am using PHP to write the result sets to a file, then including and
> using the file with javascript. I tried
>
> <META HTTP-EQUIV="expires" CONTENT="-1">
>
> but that seems to have no effect on this problem. I saw the one you
> mentioned as well and I will try it and get back.
>
> Andrew



Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Trouble with old SUS client Remy G. Windows Update 2 01-05-2006 05:20 PM
Microsoft game; Age of Empires II... MrHasselblad Windows XP Games 16 01-05-2006 07:54 AM
system slowed after upgrade revgene Windows XP Perform Maintain 9 01-05-2006 06:02 AM
Delay opening folders caused by dcom server process launcher service None Windows XP Help and Support 5 01-05-2006 02:46 AM
Windows error message Glo Windows XP Basics 41 01-05-2006 02:04 AM


All times are GMT. The time now is 09:11 PM.


Powered by vBulletin Version 3.5.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd. SEO by vBSEO 2.3.2 © 2005, Crawlability, Inc.

Cache javascript source