[thelist] How to avoid caching javascript vars

Andres Mercader AMercader at Counterp.Com
Mon Jun 26 08:53:38 CDT 2006


Hi, I'm doing a simple photo album online. I have several sections, each
section several pictures. To automate things, each session is contained
in
a folder, section1, section2, section3... and each section will have
pictures 1.jpg, 2.jpg, 3.jpg... These are not static, as I may be adding
more sections and pictures. Even more, whatever picture is today 2.jpg,
tomorrow it could be a different image, if I decide to change the order.

Then I have a .js file with code like this:

var imgspersection = new Array;     // Number of images per section

imgspersection[0] = 20;
imgspersection[1] = 15;
imgspersection[2] = 33;
imgspersection[3] = 4;
(...)

My question is, how can I make sure that the browser will not use any
pre-cached value of these variables, and that it will always load the
correct picture? Whenever I make any changes to those I need to reload
the page
a few times or even close the browser and reopen it again. In one
occasion
IE made me even restart my computer to notice the changes.

I have tried adding these lines in the php document that creates the
page
and imports the .js file, but they don't seem to have much effect:

   <meta http-equiv="no-cache">
   <meta http-equiv="expires" content="Wed, 26 Feb 1997 08:21:57 GMT">

Any suggestions?

Thanks





More information about the thelist mailing list