How to update cached .js files?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Robert Scheer

    How to update cached .js files?

    Hi.

    I have two .js files that are used on several of my pages. I made some
    changes in one of the files. When I call the pages, the old functions
    are called because of the browser's cache. What is the best way to
    update the browser's cache with the newer version of my .js file?

    Thanks,
    Robert Scheer
  • kaeli

    #2
    Re: How to update cached .js files?

    In article <cfd22ab6.04010 81011.74c5cc0c@ posting.google. com>,
    rbscheer@my-deja.com enlightened us with...[color=blue]
    > Hi.
    >
    > I have two .js files that are used on several of my pages. I made some
    > changes in one of the files. When I call the pages, the old functions
    > are called because of the browser's cache. What is the best way to
    > update the browser's cache with the newer version of my .js file?
    >[/color]

    Empty the cache (on some, control+alt+rel oad/refresh will work) or set
    browser settings to check on every page view.

    This is browser-dependent.

    In IE, it's under tools->internet options. (IE calls them temporary
    files)
    In NN, it's under preferences somewhere.

    --
    --
    ~kaeli~
    God was my co-pilot... but then we crashed in the mountains
    and I had to eat him.



    Comment

    • Robert Scheer

      #3
      Re: How to update cached .js files?

      Hi Kaeli.

      I need to do it automatically. The site is on the internet and I think
      it will be cumbersome to let my users clean the cache. Do I really
      need to ask my users to clean the cache? Is it the only way?

      Thanks,
      Robert Scheer

      kaeli <tiny_one@NOSPA M.comcast.net> wrote in message news:<MPG.1a675 e2f692d0ec3989a 97@nntp.lucent. com>...[color=blue]
      > In article <cfd22ab6.04010 81011.74c5cc0c@ posting.google. com>,
      > rbscheer@my-deja.com enlightened us with...[color=green]
      > > Hi.
      > >
      > > I have two .js files that are used on several of my pages. I made some
      > > changes in one of the files. When I call the pages, the old functions
      > > are called because of the browser's cache. What is the best way to
      > > update the browser's cache with the newer version of my .js file?
      > >[/color]
      >
      > Empty the cache (on some, control+alt+rel oad/refresh will work) or set
      > browser settings to check on every page view.
      >
      > This is browser-dependent.
      >
      > In IE, it's under tools->internet options. (IE calls them temporary
      > files)
      > In NN, it's under preferences somewhere.
      >
      > --[/color]

      Comment

      • HikksNotAtHome

        #4
        Re: How to update cached .js files?

        In article <cfd22ab6.04010 81555.73b5d22@p osting.google.c om>,
        rbscheer@my-deja.com (Robert Scheer) writes:
        [color=blue]
        >Hi Kaeli.
        >
        >I need to do it automatically. The site is on the internet and I think
        >it will be cumbersome to let my users clean the cache. Do I really
        >need to ask my users to clean the cache? Is it the only way?[/color]

        If they are getting cached .js files, how are you ensuring they get non-cached
        html files?

        And until you come up with a way to ensure they are not getting cached files,
        yes, the only way is to have them clear the cache.

        After you get it cleared up, the simplest way to ensure the file comes from the
        server is to append the current date to the name of the js file as a parameter.
        And then you are defeating the primary purpose of .js files and that is the
        repeated download of the same code. (There are more reasons than that for .js
        files but that seems to be the predominant use of them)
        --
        Randy

        Comment

        • kaeli

          #5
          Re: How to update cached .js files?

          In article <cfd22ab6.04010 81555.73b5d22@p osting.google.c om>,
          rbscheer@my-deja.com enlightened us with...[color=blue]
          > Hi Kaeli.
          >
          > I need to do it automatically. The site is on the internet and I think
          > it will be cumbersome to let my users clean the cache. Do I really
          > need to ask my users to clean the cache? Is it the only way?
          >[/color]

          Basically, yes.

          You have no real control over a user's cache (for security reasons,
          actually). You can ask nicely in some instances with meta tags, but
          IIRC, my settings can still prevent that from working.

          I have had problems with Netscape 7.1 not clearing the cache (even
          manually clearing it I still get old crap) with some sites (notably
          http://www.newsnow.co.uk/). Still can't figure out if it's my settings,
          their coding, or a bug...
          (also, it may be a proxy issue if you use one - I do)

          Expiring the file MAY help, but I'm not positive.
          Here is a link to a caching tutorial.
          Covers the how's and why's of Web caching for people who publish on the Web. With FAQs.



          --
          --
          ~kaeli~
          Press any key...NO, NO, NO, NOT THAT ONE!!!!!!



          Comment

          • Grant Wagner

            #6
            Re: How to update cached .js files?

            HikksNotAtHome wrote:
            [color=blue]
            > In article <cfd22ab6.04010 81555.73b5d22@p osting.google.c om>,
            > rbscheer@my-deja.com (Robert Scheer) writes:
            >[color=green]
            > >Hi Kaeli.
            > >
            > >I need to do it automatically. The site is on the internet and I think
            > >it will be cumbersome to let my users clean the cache. Do I really
            > >need to ask my users to clean the cache? Is it the only way?[/color]
            >
            > If they are getting cached .js files, how are you ensuring they get non-cached
            > html files?
            >
            > And until you come up with a way to ensure they are not getting cached files,
            > yes, the only way is to have them clear the cache.
            >
            > After you get it cleared up, the simplest way to ensure the file comes from the
            > server is to append the current date to the name of the js file as a parameter.
            > And then you are defeating the primary purpose of .js files and that is the
            > repeated download of the same code. (There are more reasons than that for .js
            > files but that seems to be the predominant use of them)
            > --
            > Randy[/color]

            You can append a "version" or date information without defeating the point of
            cached .js files.

            <script type="text/javascript" src="file.js?v= 200401151300"></script>

            When file.js is modified, simply change the value of "v" to something else. If you
            have access to server-side includes, this it's easy to update the occurrance on
            every page that uses this file by simply putting the <script ...></script> tags in
            an SSI.

            If not, then you'll need a tool that does search and replace across multiple files.

            --
            | Grant Wagner <gwagner@agrico reunited.com>

            * Client-side Javascript and Netscape 4 DOM Reference available at:
            *


            * Internet Explorer DOM Reference available at:
            *
            Gain technical skills through documentation and training, earn certifications and connect with the community


            * Netscape 6/7 DOM Reference available at:
            * http://www.mozilla.org/docs/dom/domref/
            * Tips for upgrading JavaScript for Netscape 7 / Mozilla
            * http://www.mozilla.org/docs/web-deve...upgrade_2.html


            Comment

            • Thomas 'PointedEars' Lahn

              #7
              Re: How to update cached .js files?

              Robert Scheer wrote:[color=blue]
              > Hi Kaeli.[/color]

              This is a public newsgroup, not private e-mail. [psf 7.21]
              [color=blue]
              > Do I really need to ask my users to clean the cache? Is it the only way?[/color]

              Yes, it is, for my cache is *my* cache.

              And please do not top-post.


              PointedEars

              Comment

              Working...