How to avoid external js file being cached ?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Homer J. Simpson

    How to avoid external js file being cached ?

    Hi there,
    Does anyone know a working tip to avoid an external js file being cached,
    whathever the client cache policy is ?

    Thanks in advance,
    J. Philippe


  • Kiran Makam

    #2
    Re: How to avoid external js file being cached ?

    Try this,

    <script>
    var dt = (new Date()).getTime ();
    document.write( "<scr"+"ipt src='file.js?ti me="+dt+"'></scr"+"ipt>" );
    </script>

    Idea behind the code is to fool the browser with a different url every
    time the page loads.
    I have not tested, see if it works.

    - Kiran Makam

    Comment

    • Homer J. Simpson

      #3
      Re: How to avoid external js file being cached ?

      Kiran,

      It seems to works perfectly.
      Just have to modify all my pages to introduce it....

      Thanks for your answer.
      J.Philippe

      "Kiran Makam" <kiranmn75@yaho o.com> a écrit dans le message de
      news:1105960764 .381243.132920@ c13g2000cwb.goo glegroups.com.. .[color=blue]
      > Try this,
      >
      > <script>
      > var dt = (new Date()).getTime ();
      > document.write( "<scr"+"ipt src='file.js?ti me="+dt+"'></scr"+"ipt>" );
      > </script>
      >
      > Idea behind the code is to fool the browser with a different url every
      > time the page loads.
      > I have not tested, see if it works.
      >
      > - Kiran Makam
      >[/color]


      Comment

      Working...