no-cache javascript

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

    #1

    no-cache javascript

    Hi, all,

    I am currently updating links for a site almost daily. I have set the
    META tags to allow for no caching so that as soon as the site is
    updated on the server, the new changes can be seen by the people
    logging onto the site.

    But I have a problem when it comes to the javascript files associated
    with the .asp files. It seems as if the javacsript files are cached,
    even though the page page calling it is not.

    So, the viewer sees my changes to the site, but has to refresh the
    page each time the person wants to view the new javascript links.

    Any ideas on what I might be able to do?

    Thanks.
  • David Dorward

    #2
    Re: no-cache javascript

    ICode wrote:
    [color=blue]
    > I am currently updating links for a site almost daily. I have set the
    > META tags to allow for no caching[/color]

    <meta http-equiv> isn't really equiv to http, and you can't put them in
    anything other then HTML documents. Try using real http headers.

    Covers the how's and why's of Web caching for people who publish on the Web. With FAQs.


    --
    David Dorward <http://blog.dorward.me .uk/> <http://dorward.me.uk/>
    Home is where the ~/.bashrc is

    Comment

    • Evertjan.

      #3
      Re: no-cache javascript

      ICode wrote on 16 jun 2004 in comp.lang.javas cript:
      [color=blue]
      > I am currently updating links for a site almost daily. I have set the
      > META tags to allow for no caching so that as soon as the site is
      > updated on the server, the new changes can be seen by the people
      > logging onto the site.
      >
      > But I have a problem when it comes to the javascript files associated
      > with the .asp files. It seems as if the javacsript files are cached,
      > even though the page page calling it is not.
      >
      > So, the viewer sees my changes to the site, but has to refresh the
      > page each time the person wants to view the new javascript links.
      >
      > Any ideas on what I might be able to do?
      >[/color]

      <script type="text/javascript"
      src="/lib/mylib.js?<%=now %>"[color=blue]
      ></script>[/color]

      not tested.

      --
      Evertjan.
      The Netherlands.
      (Please change the x'es to dots in my emailaddress)

      Comment

      • Grant Wagner

        #4
        Re: no-cache javascript

        "Evertjan." wrote:
        [color=blue]
        > ICode wrote on 16 jun 2004 in comp.lang.javas cript:
        >[color=green]
        > > I am currently updating links for a site almost daily. I have set the
        > > META tags to allow for no caching so that as soon as the site is
        > > updated on the server, the new changes can be seen by the people
        > > logging onto the site.
        > >
        > > But I have a problem when it comes to the javascript files associated
        > > with the .asp files. It seems as if the javacsript files are cached,
        > > even though the page page calling it is not.
        > >
        > > So, the viewer sees my changes to the site, but has to refresh the
        > > page each time the person wants to view the new javascript links.
        > >
        > > Any ideas on what I might be able to do?
        > >[/color]
        >
        > <script type="text/javascript"
        > src="/lib/mylib.js?<%=now %>"[color=green]
        > ></script>[/color]
        >
        > not tested.[/color]

        It works fine for refreshing external Javascript files. But unless mylib.js
        is being dynamically generated every page load, it's sort of a waste of
        bandwidth to re-retrieve it each time it's needed (it also defeats the point
        of using an external file in the first place).

        Personally I use something like:

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

        Then when I change the ASP page in a way that requires an update to the
        Javascript, I just change the [v]ersion. If you use the .js file in many
        places, then use server-side includes or a function call to embed the
        <script> tag on each page, all with the same [v]ersion.

        Even if the .js file changes intermitantly, it would be worthwhile to
        implement some sort of versioning system that only changed the stuff after
        "yourfile.j s" when it was actually necessary.

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

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


        * Internet Explorer DOM Reference available at:
        *
        http://msdn.microsoft.com/workshop/a...ence_entry.asp

        * 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

        Working...