Prev: PROJECT TRACKING SOFTWARE
Next: FAQ Topic - How do I get the value of a form control? (2010-04-08)
From: nick on 5 May 2010 20:07 On May 5, 7:43 pm, David Mark <dmark.cins...(a)gmail.com> wrote: > David Mark wrote: > > nick wrote: > >> On May 5, 7:26 pm, David Mark <dmark.cins...(a)gmail.com> wrote: > >>> FAQ server wrote: > >>>> ----------------------------------------------------------------------- > >>>> FAQ Topic - How do I force a reload from the server/prevent > >>>> caching? > >>>> ----------------------------------------------------------------------- > >>>> To reload a page, use ` location.reload() `. However, this depends > >>>> upon the cache headers that your server sends. To change this, > >>>> you need to alter the server configuration. A quick fix on the > >>>> client is to change the page URI so that it contains a unique > >>>> element, such as the current time. For example: > >>>> ` location.replace(location.href+'?d='+new Date().valueOf()) ` > >>>> If the ` location.href ` already contains a query String, use: > >>>> ` location.replace(location.href+'&d='+new Date().valueOf()) ` > >>> The valueOf calls would seem superfluous. > >> the valueOf calls give the numeric representation instead of the > >> string representation when used with + as concatenation operator. It's > >> more precise and it doesn't contain spaces. > > > The unary plus operator does the same thing. > > >> for (i=10;i--;) console.log(new Date(), '...', new Date().valueOf()) > > > Add a "+" before "new Date()". > > NM. I misread the original (I blame lousy spacing). :) Point taken, though. This works in my browser: location.replace(location.href + '?d=' + +new Date()) This might be safer? location.replace(location.href + '?d=' + (+new Date()))
From: David Mark on 5 May 2010 20:06 nick wrote: > On May 5, 7:43 pm, David Mark <dmark.cins...(a)gmail.com> wrote: >> David Mark wrote: >>> nick wrote: >>>> On May 5, 7:26 pm, David Mark <dmark.cins...(a)gmail.com> wrote: >>>>> FAQ server wrote: >>>>>> ----------------------------------------------------------------------- >>>>>> FAQ Topic - How do I force a reload from the server/prevent >>>>>> caching? >>>>>> ----------------------------------------------------------------------- >>>>>> To reload a page, use ` location.reload() `. However, this depends >>>>>> upon the cache headers that your server sends. To change this, >>>>>> you need to alter the server configuration. A quick fix on the >>>>>> client is to change the page URI so that it contains a unique >>>>>> element, such as the current time. For example: >>>>>> ` location.replace(location.href+'?d='+new Date().valueOf()) ` >>>>>> If the ` location.href ` already contains a query String, use: >>>>>> ` location.replace(location.href+'&d='+new Date().valueOf()) ` >>>>> The valueOf calls would seem superfluous. >>>> the valueOf calls give the numeric representation instead of the >>>> string representation when used with + as concatenation operator. It's >>>> more precise and it doesn't contain spaces. >>> The unary plus operator does the same thing. >>>> for (i=10;i--;) console.log(new Date(), '...', new Date().valueOf()) >>> Add a "+" before "new Date()". >> NM. I misread the original (I blame lousy spacing). :) > > Point taken, though. This works in my browser: > > location.replace(location.href + '?d=' + +new Date()) > > This might be safer? > > location.replace(location.href + '?d=' + (+new Date())) > I don't think it is safer, but it is certainly advisable for readability.
First
|
Prev
|
Pages: 1 2 Prev: PROJECT TRACKING SOFTWARE Next: FAQ Topic - How do I get the value of a form control? (2010-04-08) |